zoukankan      html  css  js  c++  java
  • 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)
    

    搞定,收工!

  • 相关阅读:
    十分钟上手-搭建vue开发环境(新手教程)
    二叉树基本操作C代码
    javaScript改变HTML
    javaScript查找HTML元素
    javaScript示例
    javaScript语法基础
    jsp useBean
    +Java中的native关键字浅析(Java+Native+Interface)++
    在myeclipse中拷贝一个工程,修改部署的名字
    解压版mysql安装
  • 原文地址:https://www.cnblogs.com/blibli/p/13268254.html
Copyright © 2011-2022 走看看