Windows 下使用 phpunit 执行的时候一直提示报错,麻烦指点一二
这是我的代码
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class TbTokenTest extends TestCase
{
public function testExample()
{
$data = '{"my_account":"ihouxin"}';
$response = $this->json('POST', '/hs/save_friend_message', ['data'=>$data]);
$response->dumpHeaders();
$response->dump();
$response->assertJson(['code'=>200]);
}
}
我使用的windows下的"phpunit.phar"工具。
在cmd命令行里面运行“phpunit”的情况下,提示报错
下面是错误截图
There was 1 error:
1) Tests\Feature\ExampleTest::testBasicTest
ErrorException: Declaration of Illuminate\Foundation\Testing\Assert::assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''): void should be compatible with PHPUnit\Framework\Assert::assertArraySubset($subset, $array, $strict = false, $message = '')
G:\WWW\wechat\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Assert.php:42
G:\WWW\wechat\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestResponse.php:164
G:\WWW\wechat\tests\Feature\ExampleTest.php:19
ERRORS!
Tests: 3, Assertions: 2, Errors: 1.
头部和内容是可以正常打印的 。就是最后会这样报错 ,是不是哪里配置错了?
看错误提示,是 laravel 中继承了 phpunit 中的方法,但是方法的参数却不同。。。
所以推测,,phpunit 版本跟 laravel 所需的版本不匹配,,,而且是低于 laravel 所需的版本,,,更新你那个 phpunit.phar 应该可以解决,,,