• phpunit 报错 ErrorException: Declaration of IlluminateFoundationTestingAssert::assertArraySubset($subset, $array, bool $checkForObjectIdentity = false, string $message = ''):


    接上文,好不容易配置好phpunit 一运行命令:

    phpunit tests/feature/exampletest
    

    报错:

    ErrorException: Declaration of IlluminateTestingAssert::assertArraySubset($subset, $array, bool $checkForIdentity = false, string $msg = ''): void should be compatible
    with PHPUnitFrameworkAssert::assertArraySubset($subset, $array, $strict = false, $message = '')
    

    解决办法:推测是因为 phpunit 版本跟 laravel 所需的版本不匹配,而且是低于 laravel 所需的版本,更新 phpunit.phar 可以解决

    查看phpunit版本命令:

    $ phpunit --version
    PHPUnit x.y.z by Sebastian Bergmann and contributors.

    重新下载最新版本的phpunit 8.5.8.phar,复制到之前安装phpunit的目录覆盖

    之后重新输入命令:

    $ phpunit --version
    PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
    

    成功了,现在我们再来单元测试:

    $ phpunit tests/feature/exampletest
    PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
    
    Warning:       Invocation with class name is deprecated
    
    .                                                                   1 / 1 (100%)
    
    Time: 213 ms, Memory: 24.00 MB
    
    OK (1 test, 1 assertion)
    

    搞定,收工!

  • 相关阅读:
    QT获取句柄
    java多线程关键字volatile、lock、synchronized
    Java几种常见的设计模式
    将博客搬至CSDN
    0228-0308的笔记
    深入理解es6-Promise对象
    彻底理解正则
    es6学习笔记-class之继承
    es6学习笔记-class之一概念
    arguments对象详解
  • 原文地址:https://www.cnblogs.com/blibli/p/13268254.html
Copyright © 2020-2023  润新知