While cleaning up the reproducing example from #3879, I ran into the following issue:
<?php
use PHPUnit\Framework\TestCase;
abstract class AbstractTest extends TestCase
{
/**
* @dataProvider provider
*/
public function testOne(string $parameter): void
{
$this->assertSame('test', $parameter);
}
public function provider(): array
{
return [
['test'],
];
}
}
final class Test extends AbstractTest
{
}
With PHPUnit 8.4.0 I get
PHPUnit 8.4.0 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Time: 34 ms, Memory: 6.00 MB
There was 1 warning:
1) Warning
Cannot instantiate class "AbstractTest".
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
With PHPUnit 8.3.5 I get
PHPUnit 8.3.5 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 34 ms, Memory: 6.00 MB
OK (1 test, 1 assertion)
@flow-control Could this be related to #3830?
Simpler reproducing test case:
<?php
use PHPUnit\Framework\TestCase;
abstract class AbstractTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}
final class Test extends AbstractTest
{
}
Could be related, i'll have look at it. How are you calling phpunit and how is the filename? Is it test.php or AbstractTest.php ?
According to git bisect, 82e7076833b78f7f716dbd346e7096966fa6117e is the first "bad commit".
@flow-control I have the code shown in https://github.com/sebastianbergmann/phpunit/issues/3881#issuecomment-538315994 in Test.php and invoke PHPUnit with phpunit Test.
For the record, this is how I bisected this:
$ cat run.sh
#!/bin/sh
composer update
./phpunit --fail-on-warning /tmp/Test.php
$ git bisect start
$ git bisect good 8.3.5
$ git bisect bad 8.4.0
$ git bisect run ./run.sh
Thanks, i found the problem and i will create a PR in the next hours to solve this. Maybe i deleted a bit too much in 82e7076 ;-)
Thank you for looking into this!
Submitted a fix in PR #3882
hope the pipeline runs :crossed_fingers:
But example from https://github.com/sebastianbergmann/phpunit/issues/3881#issue-502509561 still not working
While this https://github.com/sebastianbergmann/phpunit/issues/3881#issuecomment-538315994 is fixed
I'll have a look
@gleb-svitelskiy https://github.com/sebastianbergmann/phpunit/issues/3881#issue-502509561 is a different issue that is tracked in #3879.
I can confirm, that it fails, but with the exact same error message as described in #3879, so i assume this is going to be fixed in that Issue than.
1) Warning
The data provider specified for Issue3881DataProviderTest::testOne is invalid.
Cannot instantiate abstract class Issue3881DataProviderAbstractTest
@flow-control Exactly.
Most helpful comment
Thanks, i found the problem and i will create a PR in the next hours to solve this. Maybe i deleted a bit too much in 82e7076 ;-)