diff --git a/tests/Feature/Auth/DoctrineUserProviderTest.php b/tests/Feature/Auth/DoctrineUserProviderTest.php index 3b64d0b7..55f2995f 100644 --- a/tests/Feature/Auth/DoctrineUserProviderTest.php +++ b/tests/Feature/Auth/DoctrineUserProviderTest.php @@ -1,5 +1,7 @@ em = m::mock(EntityManagerInterface::class); $this->repo = m::mock(EntityRepository::class); - $this->provider = new DoctrineUserProvider( + $this->provider = new DoctrineUserProvider( $this->hasher, $this->em, - AuthenticableMock::class + AuthenticableMock::class, ); $this->providerNonEmpty = new DoctrineUserProvider( $this->hasher, $this->em, - AuthenticableWithNonEmptyConstructorMock::class + AuthenticableWithNonEmptyConstructorMock::class, ); parent::setUp(); } - public function test_can_retrieve_by_id() + public function testCanRetrieveById(): void { $this->mockGetRepository(); - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->repo->shouldReceive('find') ->once()->with(1) ->andReturn($user); @@ -71,22 +57,22 @@ public function test_can_retrieve_by_id() $this->assertEquals($user, $this->provider->retrieveById(1)); } - public function test_can_retrieve_by_token() + public function testCanRetrieveByToken(): void { $this->mockGetRepository(); - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->repo->shouldReceive('findOneBy') ->with([ 'id' => 1, - 'rememberToken' => 'myToken' + 'rememberToken' => 'myToken', ]) ->once()->andReturn($user); $this->assertEquals($user, $this->provider->retrieveByToken(1, 'myToken')); } - public function test_can_retrieve_by_token_with_non_empty_constructor() + public function testCanRetrieveByTokenWithNonEmptyConstructor(): void { $this->mockGetRepository(AuthenticableWithNonEmptyConstructorMock::class); @@ -94,16 +80,16 @@ public function test_can_retrieve_by_token_with_non_empty_constructor() $this->repo->shouldReceive('findOneBy') ->with([ 'id' => 1, - 'rememberToken' => 'myToken' + 'rememberToken' => 'myToken', ]) ->once()->andReturn($user); $this->assertEquals($user, $this->providerNonEmpty->retrieveByToken(1, 'myToken')); } - public function test_can_update_remember_token() + public function testCanUpdateRememberToken(): void { - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->em->shouldReceive('persist')->once()->with($user); $this->em->shouldReceive('flush')->once()->withNoArgs(); @@ -113,26 +99,24 @@ public function test_can_update_remember_token() $this->assertEquals('newToken', $user->getRememberToken()); } - public function test_can_retrieve_by_credentials() + public function testCanRetrieveByCredentials(): void { $this->mockGetRepository(); - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->repo->shouldReceive('findOneBy') - ->with([ - 'email' => 'email', - ]) + ->with(['email' => 'email']) ->once()->andReturn($user); $this->assertEquals($user, $this->provider->retrieveByCredentials([ 'email' => 'email', - 'password' => 'password' + 'password' => 'password', ])); } - public function test_can_validate_credentials() + public function testCanValidateCredentials(): void { - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->hasher->shouldReceive('check')->once() ->with('myPassword', 'myPassword') @@ -140,13 +124,13 @@ public function test_can_validate_credentials() $this->assertTrue($this->provider->validateCredentials( $user, - ['password' => 'myPassword'] + ['password' => 'myPassword'], )); } - public function test_rehash_password_if_required_rehash() + public function testRehashPasswordIfRequriredRehash(): void { - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->hasher->shouldReceive('needsRehash')->once()->andReturn(true); $this->hasher->shouldReceive('make')->once()->andReturn('hashedPassword'); @@ -157,9 +141,9 @@ public function test_rehash_password_if_required_rehash() $this->assertEquals('hashedPassword', $user->getPassword()); } - public function test_rehash_password_if_required_rehash_force() + public function testRehashPasswordIfRequiredRehashForce(): void { - $user = new AuthenticableMock; + $user = new AuthenticableMock(); $this->hasher->shouldReceive('needsRehash')->once()->andReturn(false); $this->hasher->shouldReceive('make')->once()->andReturn('hashedPassword'); @@ -170,7 +154,7 @@ public function test_rehash_password_if_required_rehash_force() $this->assertEquals('hashedPassword', $user->getPassword()); } - public function test_rehash_password_if_required_rehash_norehash_needed() + public function testRehashPasswordIfRequiredRehashNorehashNeeded(): void { $user = new AuthenticableMock(); $user->setPassword('originalPassword'); @@ -181,7 +165,7 @@ public function test_rehash_password_if_required_rehash_norehash_needed() $this->assertEquals('originalPassword', $user->getPassword()); } - protected function mockGetRepository($class = AuthenticableMock::class) + protected function mockGetRepository(string $class = AuthenticableMock::class): void { $this->em->shouldReceive('getRepository') ->with($class) diff --git a/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php b/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php index aec6c1fb..a4dec577 100644 --- a/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php +++ b/tests/Feature/Auth/Passwords/DoctrineTokenRepositoryTest.php @@ -1,10 +1,13 @@ hasher, 'password_resets', 'hashkey', - 60 + 60, ); parent::setUp(); } - public function test_can_create_a_token() + public function testCanCreateAToken(): void { $this->connection->shouldReceive('createQueryBuilder') ->twice() @@ -108,17 +93,17 @@ public function test_can_create_a_token() ->with([ 'email' => ':email', 'token' => ':token', - 'created_at' => ':date' + 'created_at' => ':date', ]) ->once()->andReturnSelf(); $this->builder->shouldReceive('setParameters') ->once()->andReturnSelf(); - $this->assertNotNull($this->repository->create(new UserMock)); + $this->assertNotNull($this->repository->create(new UserMock())); } - public function test_can_check_if_exists() + public function testCanCheckIfExists(): void { $this->connection->shouldReceive('createQueryBuilder') ->once() @@ -154,7 +139,7 @@ public function test_can_check_if_exists() ->with('email', 'user@mockery.mock') ->andReturnSelf(); - $result = m::mock(\Doctrine\DBAL\Result::class); + $result = m::mock(Result::class); $this->builder->shouldReceive('executeQuery') ->once() @@ -165,13 +150,13 @@ public function test_can_check_if_exists() ->andReturn([ 'email' => 'user@mockery.mock', 'token' => 'token', - 'created_at' => Carbon::now() + 'created_at' => Carbon::now(), ]); - $this->assertTrue($this->repository->exists(new UserMock, 'token')); + $this->assertTrue($this->repository->exists(new UserMock(), 'token')); } - public function test_can_check_if_recently_created_token() + public function testCanCheckIfRecentlyCreatedToken(): void { $this->connection->shouldReceive('createQueryBuilder') ->once() @@ -197,7 +182,7 @@ public function test_can_check_if_recently_created_token() ->with('email', 'user@mockery.mock') ->andReturnSelf(); - $result = m::mock(\Doctrine\DBAL\Result::class); + $result = m::mock(Result::class); $this->builder->shouldReceive('executeQuery') ->once() @@ -208,13 +193,13 @@ public function test_can_check_if_recently_created_token() ->andReturn([ 'email' => 'user@mockery.mock', 'token' => 'token', - 'created_at' => Carbon::now() + 'created_at' => Carbon::now(), ]); - $this->assertTrue($this->repository->recentlyCreatedToken(new UserMock)); + $this->assertTrue($this->repository->recentlyCreatedToken(new UserMock())); } - public function test_can_delete() + public function testCanDelete(): void { $this->connection->shouldReceive('createQueryBuilder') ->once() @@ -235,7 +220,6 @@ public function test_can_delete() ->with('email', 'user@mockery.mock') ->andReturnSelf(); - $this->builder->shouldReceive('executeStatement') ->once() ->andReturn(true); @@ -245,7 +229,7 @@ public function test_can_delete() $this->assertTrue(true); } - public function test_can_delete_expired() + public function testCanDeleteExpired(): void { $this->connection->shouldReceive('createQueryBuilder') ->once()