Skip to content

Commit e0aa889

Browse files
authored
PHPUnit v11 support (#262)
* PHPUnit v11 support * wip * wip
1 parent 8beabfd commit e0aa889

5 files changed

+27
-31
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"orchestra/testbench": "^7.0|^8.0|^9.0",
21-
"phpunit/phpunit": "^9.3|^10.4"
21+
"phpunit/phpunit": "^9.3|^10.4|^11.0"
2222
},
2323
"autoload": {
2424
"psr-4": {

phpunit.xml.dist

+1-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
beStrictAboutTestsThatDoNotTestAnything="true"
5-
bootstrap="vendor/autoload.php"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnError="false"
12-
stopOnFailure="false"
13-
verbose="true"
14-
>
2+
<phpunit colors="true">
153
<testsuites>
164
<testsuite name="Package Test Suite">
175
<directory suffix="Test.php">./tests</directory>
186
</testsuite>
197
</testsuites>
20-
218
<php>
229
<env name="DB_CONNECTION" value="testing"/>
2310
</php>

tests/AuthBackend/AuthenticatesUsersTest.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Illuminate\Validation\ValidationException;
1313
use Orchestra\Testbench\Factories\UserFactory;
1414
use Orchestra\Testbench\TestCase;
15+
use PHPUnit\Framework\Attributes\Test;
1516

1617
class AuthenticatesUsersTest extends TestCase
1718
{
@@ -34,7 +35,7 @@ protected function defineDatabaseMigrations()
3435
$this->loadLaravelMigrations();
3536
}
3637

37-
/** @test */
38+
#[Test]
3839
public function it_can_authenticate_a_user()
3940
{
4041
Event::fake();
@@ -57,7 +58,7 @@ public function it_can_authenticate_a_user()
5758
});
5859
}
5960

60-
/** @test */
61+
#[Test]
6162
public function it_can_authenticate_a_user_with_remember_as_false()
6263
{
6364
Event::fake();
@@ -81,9 +82,7 @@ public function it_can_authenticate_a_user_with_remember_as_false()
8182
});
8283
}
8384

84-
85-
86-
/** @test */
85+
#[Test]
8786
public function it_can_authenticate_a_user_with_remember_as_true()
8887
{
8988
Event::fake();
@@ -107,7 +106,7 @@ public function it_can_authenticate_a_user_with_remember_as_true()
107106
});
108107
}
109108

110-
/** @test */
109+
#[Test]
111110
public function it_cant_authenticate_a_user_with_invalid_password()
112111
{
113112
$user = UserFactory::new()->create();
@@ -131,7 +130,7 @@ public function it_cant_authenticate_a_user_with_invalid_password()
131130
], $response->exception->errors());
132131
}
133132

134-
/** @test */
133+
#[Test]
135134
public function it_cant_authenticate_unknown_credential()
136135
{
137136
$request = Request::create('/login', 'POST', [

tests/AuthBackend/RegistersUsersTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Validation\ValidationException;
1414
use Orchestra\Testbench\Factories\UserFactory;
1515
use Orchestra\Testbench\TestCase;
16+
use PHPUnit\Framework\Attributes\Test;
1617

1718
class RegistersUsersTest extends TestCase
1819
{
@@ -28,7 +29,7 @@ protected function defineDatabaseMigrations()
2829
$this->loadLaravelMigrations();
2930
}
3031

31-
/** @test */
32+
#[Test]
3233
public function it_can_register_a_user()
3334
{
3435
$request = Request::create('/register', 'POST', [

tests/AuthBackend/ThrottleLoginsTest.php

+17-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
namespace Laravel\Ui\Tests\AuthBackend;
44

5-
use Illuminate\Foundation\Auth\ThrottlesLogins;
5+
use Illuminate\Foundation\Auth\ThrottlesLogins as ThrottlesLoginsTrait;
66
use Orchestra\Testbench\TestCase;
77
use Illuminate\Http\Request;
8-
use PHPUnit\Framework\MockObject\MockObject;
8+
use PHPUnit\Framework\Attributes\DataProvider;
9+
use PHPUnit\Framework\Attributes\Test;
910

1011
class ThrottleLoginsTest extends TestCase
1112
{
12-
/**
13-
* @test
14-
* @dataProvider emailProvider
15-
*/
13+
#[Test]
14+
#[DataProvider('emailProvider')]
1615
public function it_can_generate_throttle_key(string $email, string $expectedEmail): void
1716
{
18-
$throttle = $this->getMockForTrait(ThrottlesLogins::class, [], '', true, true, true, ['username']);
17+
$throttle = $this->createMock(ThrottlesLogins::class);
1918
$throttle->method('username')->willReturn('email');
2019
$reflection = new \ReflectionClass($throttle);
2120
$method = $reflection->getMethod('throttleKey');
@@ -33,8 +32,18 @@ public static function emailProvider(): array
3332
return [
3433
'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', '[email protected]'],
3534
'uppercase special characters' => ['ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ', '[email protected]'],
36-
'special character numbers' =>['test⑩⓸③@laravel.com', '[email protected]'],
35+
'special character numbers' => ['test⑩⓸③@laravel.com', '[email protected]'],
3736
'default email' => ['[email protected]', '[email protected]'],
3837
];
3938
}
4039
}
40+
41+
class ThrottlesLogins
42+
{
43+
use ThrottlesLoginsTrait;
44+
45+
public function username()
46+
{
47+
return 'email';
48+
}
49+
}

0 commit comments

Comments
 (0)