Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require-dev": {
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.3|^10.4"
"phpunit/phpunit": "^9.3|^10.4|^11.0"
},
"autoload": {
"psr-4": {
Expand Down
15 changes: 1 addition & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<phpunit colors="true">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>

<php>
<env name="DB_CONNECTION" value="testing"/>
</php>
Expand Down
13 changes: 6 additions & 7 deletions tests/AuthBackend/AuthenticatesUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class AuthenticatesUsersTest extends TestCase
{
Expand All @@ -34,7 +35,7 @@ protected function defineDatabaseMigrations()
$this->loadLaravelMigrations();
}

/** @test */
#[Test]
public function it_can_authenticate_a_user()
{
Event::fake();
Expand All @@ -57,7 +58,7 @@ public function it_can_authenticate_a_user()
});
}

/** @test */
#[Test]
public function it_can_authenticate_a_user_with_remember_as_false()
{
Event::fake();
Expand All @@ -81,9 +82,7 @@ public function it_can_authenticate_a_user_with_remember_as_false()
});
}



/** @test */
#[Test]
public function it_can_authenticate_a_user_with_remember_as_true()
{
Event::fake();
Expand All @@ -107,7 +106,7 @@ public function it_can_authenticate_a_user_with_remember_as_true()
});
}

/** @test */
#[Test]
public function it_cant_authenticate_a_user_with_invalid_password()
{
$user = UserFactory::new()->create();
Expand All @@ -131,7 +130,7 @@ public function it_cant_authenticate_a_user_with_invalid_password()
], $response->exception->errors());
}

/** @test */
#[Test]
public function it_cant_authenticate_unknown_credential()
{
$request = Request::create('/login', 'POST', [
Expand Down
3 changes: 2 additions & 1 deletion tests/AuthBackend/RegistersUsersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Test;

class RegistersUsersTest extends TestCase
{
Expand All @@ -28,7 +29,7 @@ protected function defineDatabaseMigrations()
$this->loadLaravelMigrations();
}

/** @test */
#[Test]
public function it_can_register_a_user()
{
$request = Request::create('/register', 'POST', [
Expand Down
25 changes: 17 additions & 8 deletions tests/AuthBackend/ThrottleLoginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

namespace Laravel\Ui\Tests\AuthBackend;

use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\ThrottlesLogins as ThrottlesLoginsTrait;
use Orchestra\Testbench\TestCase;
use Illuminate\Http\Request;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;

class ThrottleLoginsTest extends TestCase
{
/**
* @test
* @dataProvider emailProvider
*/
#[Test]
#[DataProvider('emailProvider')]
public function it_can_generate_throttle_key(string $email, string $expectedEmail): void
{
$throttle = $this->getMockForTrait(ThrottlesLogins::class, [], '', true, true, true, ['username']);
$throttle = $this->createMock(ThrottlesLogins::class);
$throttle->method('username')->willReturn('email');
$reflection = new \ReflectionClass($throttle);
$method = $reflection->getMethod('throttleKey');
Expand All @@ -33,8 +32,18 @@ public static function emailProvider(): array
return [
'lowercase special characters' => ['ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ', '[email protected]'],
'uppercase special characters' => ['ⓉⒺⓈⓉ@ⓁⒶⓇⒶⓋⒺⓁ.ⒸⓄⓂ', '[email protected]'],
'special character numbers' =>['test⑩⓸③@laravel.com', '[email protected]'],
'special character numbers' => ['test⑩⓸③@laravel.com', '[email protected]'],
'default email' => ['[email protected]', '[email protected]'],
];
}
}

class ThrottlesLogins
{
use ThrottlesLoginsTrait;

public function username()
{
return 'email';
}
}