Skip to content

Commit bd51aba

Browse files
authored
Merge pull request #56 from bitExpert/fix/migrate_phpunit_11
Migrate to PHPUnit 11 attributes
2 parents d91b7d1 + 6fb07c6 commit bd51aba

File tree

6 files changed

+36
-63
lines changed

6 files changed

+36
-63
lines changed

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
55
colors="true"
6+
displayDetailsOnTestsThatTriggerDeprecations="true"
7+
displayDetailsOnPhpunitDeprecations="true"
8+
displayDetailsOnTestsThatTriggerWarnings="true"
9+
displayDetailsOnTestsThatTriggerErrors="true"
10+
failOnPhpunitDeprecation="false"
611
bootstrap="tests/Unit/bootstrap.php">
712
<testsuites>
813
<testsuite name="default">

tests/Unit/Events/ForceLoginRequestEventTest.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
use BitExpert\SyliusForceCustomerLoginPlugin\Events\ForceLoginRequestEvent;
1616
use BitExpert\SyliusForceCustomerLoginPlugin\Http\DefaultRouteChecker;
17+
use PHPUnit\Framework\Attributes\DataProvider;
18+
use PHPUnit\Framework\Attributes\Test;
1719
use Symfony\Bundle\SecurityBundle\Security;
1820
use Symfony\Component\HttpFoundation\Request;
1921
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -51,9 +53,7 @@ protected function setUp(): void
5153
);
5254
}
5355

54-
/**
55-
* @test
56-
*/
56+
#[Test]
5757
public function requestEventIsIgnoredForSubRequest(): void
5858
{
5959
$this->eventMock->method('isMainRequest')->willReturn(false);
@@ -63,9 +63,7 @@ public function requestEventIsIgnoredForSubRequest(): void
6363
$this->forceLoginRequestEvent->onKernelRequest($this->eventMock);
6464
}
6565

66-
/**
67-
* @test
68-
*/
66+
#[Test]
6967
public function requestEventIsIgnoredForLoggedInUser(): void
7068
{
7169
$user = $this->createMock(UserInterface::class);
@@ -79,9 +77,8 @@ public function requestEventIsIgnoredForLoggedInUser(): void
7977
$this->forceLoginRequestEvent->onKernelRequest($this->eventMock);
8078
}
8179

82-
/**
83-
* @dataProvider whitelistedUrls
84-
*/
80+
#[Test]
81+
#[DataProvider('whitelistedUrls')]
8582
public function whitelistedUrlsAlwaysGrantAccess(string $url): void
8683
{
8784
$request = Request::create($url);
@@ -95,9 +92,8 @@ public function whitelistedUrlsAlwaysGrantAccess(string $url): void
9592
$this->assertTrue(true);
9693
}
9794

98-
/**
99-
* @dataProvider whitelistedUrlsWithLocale
100-
*/
95+
#[Test]
96+
#[DataProvider('whitelistedUrlsWithLocale')]
10197
public function whitelistedUrlsWithLocaleAlwaysGrantAccess(string $url): void
10298
{
10399
$request = Request::create($url);
@@ -111,9 +107,7 @@ public function whitelistedUrlsWithLocaleAlwaysGrantAccess(string $url): void
111107
$this->assertTrue(true);
112108
}
113109

114-
/**
115-
* @test
116-
*/
110+
#[Test]
117111
public function urlWithNoAccessGrantedThrowsAccessDeniedException(): void
118112
{
119113
$this->expectException(AccessDeniedException::class);
@@ -129,9 +123,7 @@ public function urlWithNoAccessGrantedThrowsAccessDeniedException(): void
129123
$this->forceLoginRequestEvent->onKernelRequest($this->eventMock);
130124
}
131125

132-
/**
133-
* @test
134-
*/
126+
#[Test]
135127
public function accessGrantedSucceeds(): void
136128
{
137129
$url = '/taxons/caps/with-pompons';
@@ -146,11 +138,11 @@ public function accessGrantedSucceeds(): void
146138
$this->assertTrue(true);
147139
}
148140

149-
public function whitelistedUrls(): array
141+
public static function whitelistedUrls(): array
150142
{
151143
return [
152144
['/_wdt'],
153-
['/profiler'],
145+
['/_profiler'],
154146
['/admin'],
155147
['/login'],
156148
['/register'],
@@ -160,7 +152,7 @@ public function whitelistedUrls(): array
160152
];
161153
}
162154

163-
public function whitelistedUrlsWithLocale(): array
155+
public static function whitelistedUrlsWithLocale(): array
164156
{
165157
return [
166158
['/en'],

tests/Unit/Model/RegexMatcherTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,20 @@
1414

1515
use BitExpert\SyliusForceCustomerLoginPlugin\Model\RegexMatcher;
1616
use BitExpert\SyliusForceCustomerLoginPlugin\Model\WhitelistEntry;
17+
use PHPUnit\Framework\Attributes\Test;
1718
use PHPUnit\Framework\TestCase;
1819

1920
class RegexMatcherTest extends TestCase
2021
{
21-
/**
22-
* @test
23-
*/
22+
#[Test]
2423
public function checkMatcherType(): void
2524
{
2625
$matcher = new RegexMatcher();
2726

2827
$this->assertEquals('regex', $matcher->getType());
2928
}
3029

31-
/**
32-
* @test
33-
*/
30+
#[Test]
3431
public function routeIsRegexMatch(): void
3532
{
3633
$whitelistEntry = new WhitelistEntry();
@@ -43,9 +40,7 @@ public function routeIsRegexMatch(): void
4340
$this->assertTrue($matcher->isMatch($pathInfo, $whitelistEntry));
4441
}
4542

46-
/**
47-
* @test
48-
*/
43+
#[Test]
4944
public function routeIsNoRegexMatch(): void
5045
{
5146
$whitelistEntry = new WhitelistEntry();

tests/Unit/Model/StaticMatcherTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,20 @@
1414

1515
use BitExpert\SyliusForceCustomerLoginPlugin\Model\StaticMatcher;
1616
use BitExpert\SyliusForceCustomerLoginPlugin\Model\WhitelistEntry;
17+
use PHPUnit\Framework\Attributes\Test;
1718
use PHPUnit\Framework\TestCase;
1819

1920
class StaticMatcherTest extends TestCase
2021
{
21-
/**
22-
* @test
23-
*/
22+
#[Test]
2423
public function checkMatcherType(): void
2524
{
2625
$matcher = new StaticMatcher();
2726

2827
$this->assertEquals('static', $matcher->getType());
2928
}
3029

31-
/**
32-
* @test
33-
*/
30+
#[Test]
3431
public function routeIsStaticMatch(): void
3532
{
3633
$whitelistEntry = new WhitelistEntry();
@@ -43,9 +40,7 @@ public function routeIsStaticMatch(): void
4340
$this->assertTrue($matcher->isMatch($pathInfo, $whitelistEntry));
4441
}
4542

46-
/**
47-
* @test
48-
*/
43+
#[Test]
4944
public function routeIsNoStaticMatch(): void
5045
{
5146
$whitelistEntry = new WhitelistEntry();

tests/Unit/Model/WhitelistEntryTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
namespace Model;
1414

1515
use BitExpert\SyliusForceCustomerLoginPlugin\Model\WhitelistEntry;
16+
use PHPUnit\Framework\Attributes\Test;
1617
use PHPUnit\Framework\TestCase;
1718
use Sylius\Component\Core\Model\Channel;
1819

1920
class WhitelistEntryTest extends TestCase
2021
{
21-
/**
22-
* @test
23-
*/
22+
#[Test]
2423
public function addChannelToWhitelist(): void
2524
{
2625
$channel = new class() extends Channel {
@@ -38,9 +37,7 @@ public function getId()
3837
$this->assertTrue($whitelistEntry->hasChannel($channel));
3938
}
4039

41-
/**
42-
* @test
43-
*/
40+
#[Test]
4441
public function addSameChannelToWhitelistOnlyOnce(): void
4542
{
4643
$channel = new class() extends Channel {
@@ -58,9 +55,7 @@ public function getId()
5855
$this->assertCount(1, $whitelistEntry->getChannels());
5956
}
6057

61-
/**
62-
* @test
63-
*/
58+
#[Test]
6459
public function removeChannelFromWhitelist(): void
6560
{
6661
$channel = new class() extends Channel {
@@ -78,9 +73,7 @@ public function getId()
7873
$this->assertCount(0, $whitelistEntry->getChannels());
7974
}
8075

81-
/**
82-
* @test
83-
*/
76+
#[Test]
8477
public function removeChannelFromWhitelistMultipleTimesCausesNoError(): void
8578
{
8679
$channel = new class() extends Channel {

tests/Unit/Voter/RequestWhitelistVoterTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use BitExpert\SyliusForceCustomerLoginPlugin\Model\StaticMatcher;
1717
use BitExpert\SyliusForceCustomerLoginPlugin\Model\WhitelistEntry;
1818
use BitExpert\SyliusForceCustomerLoginPlugin\Voter\RequestWhitelistVoter;
19+
use PHPUnit\Framework\Attributes\Test;
1920
use PHPUnit\Framework\TestCase;
2021
use Sylius\Component\Channel\Context\ChannelContextInterface;
2122
use Sylius\Component\Core\Model\ChannelInterface;
@@ -42,9 +43,7 @@ protected function setUp(): void
4243
);
4344
}
4445

45-
/**
46-
* @test
47-
*/
46+
#[Test]
4847
public function voteAbstainForNonRequestSubjects()
4948
{
5049
$token = $this->createMock(TokenInterface::class);
@@ -55,9 +54,7 @@ public function voteAbstainForNonRequestSubjects()
5554
$this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result);
5655
}
5756

58-
/**
59-
* @test
60-
*/
57+
#[Test]
6158
public function voteGrantedWhenRequestUriMatchesWhitelistEntry()
6259
{
6360
$url = '/taxons/caps/simple/';
@@ -77,9 +74,7 @@ public function voteGrantedWhenRequestUriMatchesWhitelistEntry()
7774
$this->assertEquals(VoterInterface::ACCESS_GRANTED, $result);
7875
}
7976

80-
/**
81-
* @test
82-
*/
77+
#[Test]
8378
public function voteDeniedWhenRequestUriDoesNotMatchWhitelistEntry()
8479
{
8580
$url = '/taxons/caps/simple/';
@@ -99,9 +94,7 @@ public function voteDeniedWhenRequestUriDoesNotMatchWhitelistEntry()
9994
$this->assertEquals(VoterInterface::ACCESS_DENIED, $result);
10095
}
10196

102-
/**
103-
* @test
104-
*/
97+
#[Test]
10598
public function voteAbstainedWhenSubjectTypeDoesNotMatchString()
10699
{
107100
$url = $this->createMock(Request::class);

0 commit comments

Comments
 (0)