PHP unit 9: Test Dependencies does not work for me

Viewed 135

The following PHPUnit code has taken from their own website and it does not work for me, even though the documentation says it is working.

<?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);
    }
}

I get the following error:

  1. MultipleDependencyTest::testConsumer ArgumentCountError: Too few arguments to function MultipleDependencyTest::testConsumer(), 0 passed and exactly 2 expected`
1 Answers

Upgrading/downgrading PHPUnit and PHP versions will do the trick. Try the setup as suggested by @AymDev in the comments.

Related