简体   繁体   中英

PHPUnitTest Error when run Test in Lumen Laravel 'Undefined variable: status'

When I ran my test I got the next Error:

PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
Warning:       Invocation with class name is deprecated

ErrorException : Undefined variable: status
/opt/project/vendor/laravel/lumen-framework/src/Testing/Concerns/MakesHttpRequests.php:424

This is my code:

<?php

use Laravel\Lumen\Testing\DatabaseTransactions;

class AuthControllerTest extends TestCase
{
  use DatabaseTransactions;

  public function testLogin()
  {
    $params = ['email' => 'super@mail.com', 'password' => '12345678'];
    $response = $this->post('/web/auth/login', $params);
    $response->assertResponseStatus(200);
    $response->seeJsonStructure(['data', 'message']);
  }

}

phpunit.xml file

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
         bootstrap="vendor/autoload.php"
         colors="true">
<testsuites>
  <testsuite name="Application Test Suite">
    <directory suffix="Test.php">./tests</directory>
  </testsuite>
</testsuites>
<filter>
  <whitelist processUncoveredFilesFromWhitelist="true">
    <directory suffix=".php">./app</directory>
  </whitelist>
</filter>
<php>
  <env name="APP_ENV" value="testing"/>
  <env name="CACHE_DRIVER" value="array"/>
  <env name="QUEUE_CONNECTION" value="sync"/>
</php>
</phpunit>

Composer file

...
"require": {
        "php": "^7.2.5",
        "barryvdh/laravel-dompdf": "^0.8",
        "guzzlehttp/guzzle": "^6.5",
        "illuminate/mail": "7.1.1",
        "illuminate/redis": "^7.1",
        "laravel-doctrine/orm": "1.6",
        "laravel/lumen-framework": "^7.0",
        "lcobucci/jwt": "^3.2",
        "palanik/lumen-cors": "dev-master",
        "phpmailer/phpmailer": "^6.1.4",
        "predis/predis": "^1.1"
    },
    "require-dev": {
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "phpunit/phpunit": "^8.5",
        "squizlabs/php_codesniffer": "^3.1"
    },
...

PHP Version 7.2.21

I am testing my code in a container with a docker, I don't know if the latter is relevant. That is the response debugged, the value of status is presented, so I don't understand why PHPUnit throws the error.

调试测试

Thanks for your support.

这是laravel/lumen-framework上的一个错误,应该在 7.0.1 版中修复: https : //github.com/laravel/lumen-framework/pull/1044

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM