Skip to content

Commit 1722216

Browse files
author
Brian Faust
authored
Use PHP attributes for PHPUnit tests (#631)
1 parent 99120c9 commit 1722216

26 files changed

+122
-232
lines changed

src/Generators/PhpUnitTestGenerator.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function output(Tree $tree): array
5252
/** @var \Blueprint\Models\Controller $controller */
5353
foreach ($tree->controllers() as $controller) {
5454
$this->addImport($controller, \Tests\TestCase::class);
55+
$this->addImport($controller, 'PHPUnit\Framework\Attributes\Test');
5556

5657
$path = $this->getPath($controller);
5758

@@ -531,9 +532,7 @@ private function buildFormRequestName(Controller $controller, string $name)
531532
private function buildFormRequestTestCase(string $controller, string $action, string $form_request)
532533
{
533534
return <<< END
534-
/**
535-
* @test
536-
*/
535+
#[Test]
537536
public function ${action}_uses_form_request_validation(): void
538537
{
539538
\$this->assertActionUsesFormRequest(

stubs/phpunit.test.case.stub

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* @test
3-
*/
1+
#[Test]
42
public function {{ method }}(): void
53
{
64
{{ body }}

stubs/phpunit.test.class.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace {{ namespace }};
77
/**
88
* @see {{ namespacedClass }}
99
*/
10-
class {{ class }} extends TestCase
10+
final class {{ class }} extends TestCase
1111
{
1212
{{ body }}
1313
}

tests/Feature/Commands/BuildCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use Blueprint\Blueprint;
66
use Blueprint\Builder;
77
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
8-
use PHPUnit\Framework\Attributes\CoversClass;
98
use PHPUnit\Framework\Attributes\Test;
109
use Tests\TestCase;
1110

12-
#[CoversClass(\Blueprint\Commands\BuildCommand::class)]
11+
/**
12+
* @see \Blueprint\Commands\BuildCommand
13+
*/
1314
final class BuildCommandTest extends TestCase
1415
{
1516
use MockeryPHPUnitIntegration;

tests/Feature/Commands/EraseCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
use Blueprint\Blueprint;
66
use Blueprint\Tracer;
77
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
8-
use PHPUnit\Framework\Attributes\CoversClass;
98
use PHPUnit\Framework\Attributes\Test;
109
use Tests\TestCase;
1110

12-
#[CoversClass(\Blueprint\Commands\EraseCommand::class)]
11+
/**
12+
* @see \Blueprint\Commands\EraseCommand
13+
*/
1314
final class EraseCommandTest extends TestCase
1415
{
1516
use MockeryPHPUnitIntegration;

tests/Feature/Commands/InitCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Tests\Feature\Commands;
44

55
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
6-
use PHPUnit\Framework\Attributes\CoversClass;
76
use PHPUnit\Framework\Attributes\Test;
87
use Tests\TestCase;
98

10-
#[CoversClass(\Blueprint\Commands\InitCommand::class)]
9+
/**
10+
* @see \Blueprint\Commands\InitCommand
11+
*/
1112
final class InitCommandTest extends TestCase
1213
{
1314
use MockeryPHPUnitIntegration;

tests/Feature/Commands/NewCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Tests\Feature\Commands;
44

55
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
6-
use PHPUnit\Framework\Attributes\CoversClass;
76
use PHPUnit\Framework\Attributes\Test;
87
use Tests\TestCase;
98

10-
#[CoversClass(\Blueprint\Commands\NewCommand::class)]
9+
/**
10+
* @see \Blueprint\Commands\NewCommand
11+
*/
1112
final class NewCommandTest extends TestCase
1213
{
1314
use MockeryPHPUnitIntegration;

tests/Feature/Commands/TraceCommandTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
use Blueprint\Builder;
77
use Blueprint\Tracer;
88
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
9-
use PHPUnit\Framework\Attributes\CoversClass;
109
use PHPUnit\Framework\Attributes\Test;
1110
use Symfony\Component\Yaml\Yaml;
1211
use Tests\TestCase;
1312

14-
#[CoversClass(\Blueprint\Commands\TraceCommand::class)]
13+
/**
14+
* @see \Blueprint\Commands\TraceCommand
15+
*/
1516
final class TraceCommandTest extends TestCase
1617
{
1718
use MockeryPHPUnitIntegration;

tests/Unit/EnumTypeTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace Tests\Unit;
44

5-
use PHPUnit\Framework\Attributes\CoversClass;
65
use PHPUnit\Framework\Attributes\DataProvider;
76
use PHPUnit\Framework\Attributes\Test;
87
use Tests\TestCase;
98

10-
#[CoversClass(\Blueprint\EnumType::class)]
9+
/**
10+
* @see \Blueprint\EnumType
11+
*/
1112
final class EnumTypeTest extends TestCase
1213
{
1314
#[Test]

tests/Unit/TreeTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use Blueprint\Tree;
66
use InvalidArgumentException;
7-
use PHPUnit\Framework\Attributes\CoversClass;
87
use PHPUnit\Framework\Attributes\Test;
98
use Tests\TestCase;
109

11-
#[CoversClass(\Blueprint\Tree::class)]
10+
/**
11+
* @see \Blueprint\Tree
12+
*/
1213
final class TreeTest extends TestCase
1314
{
1415
#[Test]

0 commit comments

Comments
 (0)