Chaining multiple ->coversClass calls work fine on an it block, but only one works on a describe block. Even worse, as soon as you chain more than one, none work.
How to Reproduce
describe('Test', function (): void {
it('should work', function (): void {
expect(value: true)->toBeTrue();
});
})->coversClass(\PHPUnit\Framework\TestCase::class)
->coversClass(\Orchestra\Testbench\TestCase::class)
;
describe('Other', function (): void {
it('should work', function (): void {
expect(value: true)->toBeTrue();
});
})->coversClass(\Tests\TestCase::class)
;
describe('Third', function (): void {
it('should work', function (): void {
expect(value: true)->toBeTrue();
});
})->coversClass(\Laravel\Dusk\TestCase::class)
;
Dumping the generated test class gives this (abbreviated):
namespace P\Tests\php\Unit\Test;
use Pest\Repositories\DatasetsRepository as __PestDatasets;
use Pest\TestSuite as __PestTestSuite;
/**
* @testdox C:\devel\module-laravel-app\tests\php\Unit\Test\BTest.php
*/
#[\PHPUnit\Framework\Attributes\CoversClass(\Tests\TestCase::class)]
#[\PHPUnit\Framework\Attributes\CoversClass(\Laravel\Dusk\TestCase::class)]
#[\AllowDynamicProperties]
final class BTest extends \PHPUnit\Framework\TestCase implements \Pest\Contracts\HasPrintableTestCaseName {
use \Pest\Concerns\Testable, \Pest\Concerns\Expectable, \Pest\Arch\Concerns\Architectable;
// ...
}
As can be seen the chained calls are ignored while the single calls work fine and get accumulated properly.
What Happened
Chaining multiple
->coversClass
calls work fine on anit
block, but only one works on adescribe
block. Even worse, as soon as you chain more than one, none work.How to Reproduce
Dumping the generated test class gives this (abbreviated):
As can be seen the chained calls are ignored while the single calls work fine and get accumulated properly.
Sample Repository
No response
Pest Version
2.16.0
PHP Version
8.2.9
Operation System
Windows
Notes
No response