Skip to content

Commit 8a0d350

Browse files
committed
refactor: use PHPUnit native PHP attributes instead of docblock annotations
1 parent 785decc commit 8a0d350

10 files changed

+42
-46
lines changed

tests/Api/IllustrationRequestTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
use GuzzleHttp\Handler\MockHandler;
1111
use GuzzleHttp\HandlerStack;
1212
use GuzzleHttp\Psr7\Response;
13+
use PHPUnit\Framework\Attributes\Test;
1314
use Psr\Http\Message\ResponseInterface;
1415

1516
final class IllustrationRequestTest extends TestCase
1617
{
17-
/** @test */
18+
#[Test]
1819
public function it_should_return_an_illustration_response_correctly(): void
1920
{
2021
// Arrange

tests/Api/IllustrationResponseTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
use BladeComponents\Undraw\Api\IllustrationResponse;
88
use BladeComponents\Undraw\Tests\TestCase;
99
use GuzzleHttp\Psr7\Response;
10+
use PHPUnit\Framework\Attributes\Test;
1011

1112
final class IllustrationResponseTest extends TestCase
1213
{
13-
/** @test */
14+
#[Test]
1415
public function it_should_receive_the_response_content_correctly(): void
1516
{
1617
// Arrange

tests/Api/IllustrationTest.php

+8-21
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66

77
use BladeComponents\Undraw\Api\Illustration;
88
use BladeComponents\Undraw\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\DataProvider;
10+
use PHPUnit\Framework\Attributes\Test;
911

1012
final class IllustrationTest extends TestCase
1113
{
12-
/**
13-
* @test
14-
* @dataProvider slugDataProvider
15-
*
16-
* @param string $title
17-
* @param string $expectedSlug
18-
*/
14+
#[Test]
15+
#[DataProvider('slugDataProvider')]
1916
public function it_should_covert_the_title_to_a_slug_correctly(string $title, string $expectedSlug): void
2017
{
2118
// Arrange
@@ -37,13 +34,8 @@ public static function slugDataProvider(): array
3734
];
3835
}
3936

40-
/**
41-
* @test
42-
* @dataProvider snakeDataProvider
43-
*
44-
* @param string $title
45-
* @param string $expectedSnake
46-
*/
37+
#[Test]
38+
#[DataProvider('snakeDataProvider')]
4739
public function it_should_covert_the_title_to_a_snake_correctly(string $title, string $expectedSnake): void
4840
{
4941
// Arrange
@@ -65,13 +57,8 @@ public static function snakeDataProvider(): array
6557
];
6658
}
6759

68-
/**
69-
* @test
70-
* @dataProvider studlyDataProvider
71-
*
72-
* @param string $title
73-
* @param string $expectedStudly
74-
*/
60+
#[Test]
61+
#[DataProvider('studlyDataProvider')]
7562
public function it_should_covert_the_title_to_a_studly_correctly(string $title, string $expectedStudly): void
7663
{
7764
// Arrange

tests/Api/IllustrationsRequestTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
use GuzzleHttp\Handler\MockHandler;
1212
use GuzzleHttp\HandlerStack;
1313
use GuzzleHttp\Psr7\Response;
14+
use PHPUnit\Framework\Attributes\Test;
1415
use Psr\Http\Message\ResponseInterface;
1516

1617
final class IllustrationsRequestTest extends TestCase
1718
{
18-
/** @test */
19+
#[Test]
1920
public function it_should_return_a_page_correctly(): void
2021
{
2122
// Arrange

tests/Api/IllustrationsResponseTest.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
use BladeComponents\Undraw\Api\IllustrationsResponse;
99
use BladeComponents\Undraw\Tests\TestCase;
1010
use GuzzleHttp\Psr7\Response;
11+
use PHPUnit\Framework\Attributes\Test;
1112

1213
final class IllustrationsResponseTest extends TestCase
1314
{
14-
/** @test */
15+
#[Test]
1516
public function it_should_return_the_next_page_correctly(): void
1617
{
1718
// Arrange
@@ -26,7 +27,7 @@ public function it_should_return_the_next_page_correctly(): void
2627
$this->assertSame($expectedNextPage, $nextPage);
2728
}
2829

29-
/** @test */
30+
#[Test]
3031
public function it_should_return_zero_for_next_page_when_the_status_code_is_not_200(): void
3132
{
3233
// Arrange
@@ -46,7 +47,7 @@ public function it_should_return_zero_for_next_page_when_the_status_code_is_not_
4647
$this->assertSame($expectedNextPage, $nextPage);
4748
}
4849

49-
/** @test */
50+
#[Test]
5051
public function it_should_return_true_when_there_are_more_pages(): void
5152
{
5253
// Arrange
@@ -60,7 +61,7 @@ public function it_should_return_true_when_there_are_more_pages(): void
6061
$this->assertTrue($hasMore);
6162
}
6263

63-
/** @test */
64+
#[Test]
6465
public function it_should_return_false_for_has_more_when_the_status_code_is_not_200(): void
6566
{
6667
// Arrange
@@ -79,7 +80,7 @@ public function it_should_return_false_for_has_more_when_the_status_code_is_not_
7980
$this->assertFalse($hasMore);
8081
}
8182

82-
/** @test */
83+
#[Test]
8384
public function it_returns_an_empty_array_when_the_status_code_is_not_200(): void
8485
{
8586
// Arrange
@@ -98,7 +99,7 @@ public function it_returns_an_empty_array_when_the_status_code_is_not_200(): voi
9899
$this->assertEmpty($illustrations);
99100
}
100101

101-
/** @test */
102+
#[Test]
102103
public function it_returns_an_empty_array_when_there_are_no_illustrations(): void
103104
{
104105
// Arrange
@@ -112,7 +113,7 @@ public function it_returns_an_empty_array_when_there_are_no_illustrations(): voi
112113
$this->assertEmpty($illustrations);
113114
}
114115

115-
/** @test */
116+
#[Test]
116117
public function it_returns_a_list_of_illustrations(): void
117118
{
118119
// Arrange

tests/Api/UndrawClientTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
use BladeComponents\Undraw\Api\UndrawClient;
88
use BladeComponents\Undraw\Tests\TestCase;
99
use GuzzleHttp\Psr7\Uri;
10+
use PHPUnit\Framework\Attributes\Test;
1011

1112
final class UndrawClientTest extends TestCase
1213
{
13-
/** @test */
14+
#[Test]
1415
public function it_should_set_the_base_uri_correctly(): void
1516
{
1617
// Arrange

tests/Components/BaseComponentTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use BladeComponents\Undraw\Components\UndrawComponent;
88
use BladeComponents\Undraw\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
final class BaseComponentTest extends TestCase
1112
{
12-
/** @test */
13+
#[Test]
1314
public function it_has_a_color_by_default(): void
1415
{
1516
// Arrange
@@ -24,7 +25,7 @@ public function it_has_a_color_by_default(): void
2425
$this->assertSame($expectedColor, $color);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_change_the_color(): void
2930
{
3031
// Arrange
@@ -39,7 +40,7 @@ public function it_can_change_the_color(): void
3940
$this->assertSame($expectedColor, $color);
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function it_should_generate_the_view_name_correctly(): void
4445
{
4546
// Arrange
@@ -53,7 +54,7 @@ public function it_should_generate_the_view_name_correctly(): void
5354
$this->assertSame($expectedViewName, $name);
5455
}
5556

56-
/** @test */
57+
#[Test]
5758
public function it_should_generate_the_view_name_correctly_when_using_different_separators(): void
5859
{
5960
// Arrange
@@ -65,7 +66,7 @@ public function it_should_generate_the_view_name_correctly_when_using_different_
6566
$this->assertSame($expectedViewName, (new UndrawComponent('3d modeling'))->render()->name());
6667
}
6768

68-
/** @test */
69+
#[Test]
6970
public function it_should_generate_the_illustration_name_based_on_the_class_name(): void
7071
{
7172
// Arrange

tests/Components/Illustrations/Undraw3dModelingComponentTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use BladeComponents\Undraw\Components\Illustrations\Undraw3dModelingComponent;
88
use BladeComponents\Undraw\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
final class Undraw3dModelingComponentTest extends TestCase
1112
{
12-
/** @test */
13+
#[Test]
1314
public function it_has_a_color_by_default(): void
1415
{
1516
// Arrange
@@ -24,7 +25,7 @@ public function it_has_a_color_by_default(): void
2425
$this->assertSame($expectedColor, $color);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_change_the_color(): void
2930
{
3031
// Arrange
@@ -39,7 +40,7 @@ public function it_can_change_the_color(): void
3940
$this->assertSame($expectedColor, $color);
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function it_should_generate_the_view_name_correctly(): void
4445
{
4546
// Arrange

tests/Components/Illustrations/UndrawAbstractComponentTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use BladeComponents\Undraw\Components\Illustrations\UndrawAbstractComponent;
88
use BladeComponents\Undraw\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
final class UndrawAbstractComponentTest extends TestCase
1112
{
12-
/** @test */
13+
#[Test]
1314
public function it_has_a_color_by_default(): void
1415
{
1516
// Arrange
@@ -24,7 +25,7 @@ public function it_has_a_color_by_default(): void
2425
$this->assertSame($expectedColor, $color);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_change_the_color(): void
2930
{
3031
// Arrange
@@ -39,7 +40,7 @@ public function it_can_change_the_color(): void
3940
$this->assertSame($expectedColor, $color);
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function it_should_generate_the_view_name_correctly(): void
4445
{
4546
// Arrange

tests/Components/Illustrations/UndrawBuildYourHomeComponentTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use BladeComponents\Undraw\Components\Illustrations\UndrawBuildYourHomeComponent;
88
use BladeComponents\Undraw\Tests\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
final class UndrawBuildYourHomeComponentTest extends TestCase
1112
{
12-
/** @test */
13+
#[Test]
1314
public function it_has_a_color_by_default(): void
1415
{
1516
// Arrange
@@ -24,7 +25,7 @@ public function it_has_a_color_by_default(): void
2425
$this->assertSame($expectedColor, $color);
2526
}
2627

27-
/** @test */
28+
#[Test]
2829
public function it_can_change_the_color(): void
2930
{
3031
// Arrange
@@ -39,7 +40,7 @@ public function it_can_change_the_color(): void
3940
$this->assertSame($expectedColor, $color);
4041
}
4142

42-
/** @test */
43+
#[Test]
4344
public function it_should_generate_the_view_name_correctly(): void
4445
{
4546
// Arrange

0 commit comments

Comments
 (0)