From 477492fdd2fa6e220aaac77d3a2f2fb9ab2af9c3 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sat, 6 May 2023 08:43:19 +0100 Subject: [PATCH] Adding tests --- tests/Features/Covers.php | 8 ++++++++ tests/Fixtures/Covers/CoversTrait.php | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/Fixtures/Covers/CoversTrait.php diff --git a/tests/Features/Covers.php b/tests/Features/Covers.php index 3ee6ae81..12ec4ac5 100644 --- a/tests/Features/Covers.php +++ b/tests/Features/Covers.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use Tests\Fixtures\Covers\CoversClass1; use Tests\Fixtures\Covers\CoversClass2; use Tests\Fixtures\Covers\CoversClass3; +use Tests\Fixtures\Covers\CoversTrait; $runCounter = 0; @@ -43,6 +44,13 @@ it('guesses if the given argument is a class or function', function () { expect($attributes[3]->getArguments()[0])->toBe(CoversClass3::class); })->covers(CoversClass3::class, 'testCoversFunction'); +it('uses the correct PHPUnit attribute for trait', function () { + $attributes = (new ReflectionClass($this))->getAttributes(); + + expect($attributes[4]->getName())->toBe('PHPUnit\Framework\Attributes\CoversClass'); + expect($attributes[4]->getArguments()[0])->toBe('Tests\Fixtures\Covers\CoversTrait'); +})->coversClass(CoversTrait::class); + it('appends CoversNothing to method attributes', function () { $phpDoc = (new ReflectionClass($this))->getMethod($this->name()); diff --git a/tests/Fixtures/Covers/CoversTrait.php b/tests/Fixtures/Covers/CoversTrait.php new file mode 100644 index 00000000..9d660edb --- /dev/null +++ b/tests/Fixtures/Covers/CoversTrait.php @@ -0,0 +1,8 @@ +