PHP 单元 9 : Test Dependencies does not work for me

标签 php phpunit

以下 PHPUnit 代码取自他们自己的网站,它对我不起作用,即使文档说它正在工作。

<?php declare(strict_types=1);

use PHPUnit\Framework\TestCase;

final class MultipleDependenciesTest extends TestCase
{
    public function testProducerFirst(): string
    {
        $this->assertTrue(true);
        return 'first';
    }
    
    public function testProducerSecond(): string
    {
        $this->assertTrue(true);
        return 'second';
    }
    
    /**
     * @depends testProducerFirst
     * @depends testProducerSecond
     */
    public function testConsumer(string $a, string $b): void
    {
        $this->assertSame('first', $a);
        $this->assertSame('second', $b);
    }
}
我收到以下错误:
  1. MultipleDependencyTest::testConsumer ArgumentCountError: Too few arguments to function MultipleDependencyTest::testConsumer(), 0 passed and exactly 2 expected`

最佳答案

升级/降级 PHPUnit 和 PHP 版本即可解决问题。尝试按照@AymDev 在评论中的建议进行设置。

关于PHP 单元 9 : Test Dependencies does not work for me,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65140646/

相关文章:

php - Phalcon 未定义的命名空间 Phalcon

php - 为什么我需要 `str_pad(' ',4096)` 才能使 PHP 刷新工作?

php - 使用 Laravel 4 查询生成器计算时间戳

php - 简单迁移后 Laravel 测试失败

php - Symfony2 验收测试不起作用

php - symfony2 phpunit : how to get exception message when status code is not expected one

php - Slim - 从浏览器调用端点工作正常,而从 PHPUnit 测试调用端点返回 404

php - 停止/重新启动 Gearmand

php - 从 2016 年 3 月 3 日开始每三个星期四回显

php - 如何找到为什么 phpunit testsuite 使用 xdebug 太慢?