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.

头部和内容是可以正常打印的 。就是最后会这样报错 ,是不是哪里配置错了?

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
最佳答案

看错误提示,是 laravel 中继承了 phpunit 中的方法,但是方法的参数却不同。。。

所以推测,,phpunit 版本跟 laravel 所需的版本不匹配,,,而且是低于 laravel 所需的版本,,,更新你那个 phpunit.phar 应该可以解决,,,

5年前 评论
讨论数量: 2

看错误提示,是 laravel 中继承了 phpunit 中的方法,但是方法的参数却不同。。。

所以推测,,phpunit 版本跟 laravel 所需的版本不匹配,,,而且是低于 laravel 所需的版本,,,更新你那个 phpunit.phar 应该可以解决,,,

5年前 评论

@largezhou
是的,你说的对,确实是这样的。
我的laravel版本是v6.2.0。
现在换了phpunit-7.0.3.phar,这版本就可以正常使用了。多谢指导。

之前试过了,phpunit-6.2.4.phar,phpunit-6.5.3.phar,这两个都是不行。因为他的官方文档只是提供了这两个链接,我就以为应该不是这个问题。后来我去了github上下载了最新的phpunit-7.0.3就正常了。

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!