mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
move coversNothing to method annotations
This commit is contained in:
@ -35,37 +35,42 @@ it('uses the correct PHPUnit attribute for function', function () {
|
||||
expect($attributes[1]->getArguments()[0])->toBe('foo');
|
||||
})->coversFunction('foo');
|
||||
|
||||
it('uses the correct PHPUnit attribute for nothing', function () {
|
||||
$attributes = (new ReflectionClass($this))->getAttributes();
|
||||
|
||||
expect($attributes[2]->getName())->toBe('PHPUnit\Framework\Attributes\CoversNothing');
|
||||
})->coversNothing();
|
||||
|
||||
it('removes duplicated attributes', function () {
|
||||
$attributes = (new ReflectionClass($this))->getAttributes();
|
||||
|
||||
expect($attributes[2]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass');
|
||||
expect($attributes[2]->getArguments()[0])->toBe('P\Tests\Features\TestCoversClass2');
|
||||
expect($attributes[3]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass');
|
||||
expect($attributes[3]->getArguments()[0])->toBe('P\Tests\Features\TestCoversClass2');
|
||||
expect($attributes[4]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass');
|
||||
expect($attributes[4]->getArguments()[0])->toBe('Pest\Factories\Attributes\Covers');
|
||||
expect($attributes[3]->getArguments()[0])->toBe('Pest\Factories\Attributes\Covers');
|
||||
expect($attributes[4]->getName())->toBe('PHPUnit\Framework\Attributes\CoversFunction');
|
||||
expect($attributes[4]->getArguments()[0])->toBe('bar');
|
||||
expect($attributes[5]->getName())->toBe('PHPUnit\Framework\Attributes\CoversFunction');
|
||||
expect($attributes[5]->getArguments()[0])->toBe('bar');
|
||||
expect($attributes[6]->getName())->toBe('PHPUnit\Framework\Attributes\CoversFunction');
|
||||
expect($attributes[6]->getArguments()[0])->toBe('baz');
|
||||
expect($attributes[5]->getArguments()[0])->toBe('baz');
|
||||
})
|
||||
->coversClass(TestCoversClass2::class, TestCoversClass1::class, Covers::class)
|
||||
->coversNothing()
|
||||
->coversFunction('bar', 'foo', 'baz');
|
||||
|
||||
it('guesses if the given argument is a class or function', function () {
|
||||
$attributes = (new ReflectionClass($this))->getAttributes();
|
||||
|
||||
expect($attributes[7]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass');
|
||||
expect($attributes[7]->getArguments()[0])->toBe('P\Tests\Features\TestCoversClass3');
|
||||
expect($attributes[8]->getName())->toBe('PHPUnit\Framework\Attributes\CoversFunction');
|
||||
expect($attributes[8]->getArguments()[0])->toBe('testCoversFunction');
|
||||
expect($attributes[6]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass');
|
||||
expect($attributes[6]->getArguments()[0])->toBe('P\Tests\Features\TestCoversClass3');
|
||||
expect($attributes[7]->getName())->toBe('PHPUnit\Framework\Attributes\CoversFunction');
|
||||
expect($attributes[7]->getArguments()[0])->toBe('testCoversFunction');
|
||||
})->covers(TestCoversClass3::class, 'testCoversFunction');
|
||||
|
||||
it('appends CoversNothing to method attributes', function () {
|
||||
$phpDoc = (new ReflectionClass($this))->getMethod($this->getName());
|
||||
|
||||
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeTrue();
|
||||
})->coversNothing();
|
||||
|
||||
it('does not append CoversNothing to other methods', function () {
|
||||
$phpDoc = (new ReflectionClass($this))->getMethod($this->getName());
|
||||
|
||||
expect(str_contains($phpDoc->getDocComment(), '* @coversNothing'))->toBeFalse();
|
||||
});
|
||||
|
||||
it('throws exception if no class nor method has been found', function () {
|
||||
$testCall = new TestCall(TestSuite::getInstance(), 'filename', 'description', fn () => 'closure');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user