diff --git a/tests/Unit/AccessTokenControllerTest.php b/tests/Unit/AccessTokenControllerTest.php index 4efd11a3..6471ad9f 100644 --- a/tests/Unit/AccessTokenControllerTest.php +++ b/tests/Unit/AccessTokenControllerTest.php @@ -6,6 +6,7 @@ use Laravel\Passport\Http\Controllers\AccessTokenController; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\Exception\OAuthServerException as LeagueException; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use Nyholm\Psr7\Response; use PHPUnit\Framework\TestCase; @@ -14,10 +15,7 @@ class AccessTokenControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_a_token_can_be_issued() { diff --git a/tests/Unit/AccessTokenTest.php b/tests/Unit/AccessTokenTest.php index 771dcbe1..db2ea1de 100644 --- a/tests/Unit/AccessTokenTest.php +++ b/tests/Unit/AccessTokenTest.php @@ -11,8 +11,6 @@ class AccessTokenTest extends TestCase { protected function tearDown(): void { - parent::tearDown(); - Passport::$withInheritedScopes = false; } diff --git a/tests/Unit/ApiTokenCookieFactoryTest.php b/tests/Unit/ApiTokenCookieFactoryTest.php index 1a82bbfb..ced45544 100644 --- a/tests/Unit/ApiTokenCookieFactoryTest.php +++ b/tests/Unit/ApiTokenCookieFactoryTest.php @@ -7,16 +7,14 @@ use Illuminate\Encryption\Encrypter; use Laravel\Passport\ApiTokenCookieFactory; use Laravel\Passport\Passport; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Cookie; class ApiTokenCookieFactoryTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_cookie_can_be_successfully_created() { diff --git a/tests/Unit/ApproveAuthorizationControllerTest.php b/tests/Unit/ApproveAuthorizationControllerTest.php index b572441c..646ee555 100644 --- a/tests/Unit/ApproveAuthorizationControllerTest.php +++ b/tests/Unit/ApproveAuthorizationControllerTest.php @@ -6,6 +6,7 @@ use Laravel\Passport\Http\Controllers\ApproveAuthorizationController; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\RequestTypes\AuthorizationRequest; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use Nyholm\Psr7\Response; use PHPUnit\Framework\TestCase; @@ -13,10 +14,7 @@ class ApproveAuthorizationControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_complete_authorization_request() { diff --git a/tests/Unit/AuthorizationControllerTest.php b/tests/Unit/AuthorizationControllerTest.php index a653e16a..876ebe71 100644 --- a/tests/Unit/AuthorizationControllerTest.php +++ b/tests/Unit/AuthorizationControllerTest.php @@ -17,6 +17,7 @@ use League\OAuth2\Server\Exception\OAuthServerException as LeagueException; use League\OAuth2\Server\RequestTypes\AuthorizationRequest; use League\OAuth2\Server\RequestTypes\AuthorizationRequestInterface; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use Nyholm\Psr7\Response; use PHPUnit\Framework\TestCase; @@ -25,10 +26,7 @@ class AuthorizationControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_authorization_view_is_presented() { diff --git a/tests/Unit/AuthorizedAccessTokenControllerTest.php b/tests/Unit/AuthorizedAccessTokenControllerTest.php index 1fc48c71..25fdb512 100644 --- a/tests/Unit/AuthorizedAccessTokenControllerTest.php +++ b/tests/Unit/AuthorizedAccessTokenControllerTest.php @@ -8,12 +8,14 @@ use Laravel\Passport\RefreshTokenRepository; use Laravel\Passport\Token; use Laravel\Passport\TokenRepository; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response; class AuthorizedAccessTokenControllerTest extends TestCase { + use MockeryPHPUnitIntegration; /** * @var \Mockery\Mock|\Laravel\Passport\TokenRepository */ diff --git a/tests/Unit/BridgeAccessTokenRepositoryTest.php b/tests/Unit/BridgeAccessTokenRepositoryTest.php index 9405eac2..cd2e982e 100644 --- a/tests/Unit/BridgeAccessTokenRepositoryTest.php +++ b/tests/Unit/BridgeAccessTokenRepositoryTest.php @@ -10,15 +10,13 @@ use Laravel\Passport\Bridge\Client; use Laravel\Passport\Bridge\Scope; use Laravel\Passport\TokenRepository; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class BridgeAccessTokenRepositoryTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_access_tokens_can_be_persisted() { @@ -59,8 +57,6 @@ public function test_access_tokens_can_be_revoked() $repository = new AccessTokenRepository($tokenRepository, $events); $repository->revokeAccessToken('token-id'); - - $this->expectNotToPerformAssertions(); } public function test_access_token_revoke_event_is_not_dispatched_when_nothing_happened() @@ -73,8 +69,6 @@ public function test_access_token_revoke_event_is_not_dispatched_when_nothing_ha $repository = new AccessTokenRepository($tokenRepository, $events); $repository->revokeAccessToken('token-id'); - - $this->expectNotToPerformAssertions(); } public function test_can_get_new_access_token() diff --git a/tests/Unit/BridgeClientRepositoryTest.php b/tests/Unit/BridgeClientRepositoryTest.php index eb127832..a5330d77 100644 --- a/tests/Unit/BridgeClientRepositoryTest.php +++ b/tests/Unit/BridgeClientRepositoryTest.php @@ -6,11 +6,14 @@ use Laravel\Passport\Bridge\Client; use Laravel\Passport\Bridge\ClientRepository as BridgeClientRepository; use Laravel\Passport\ClientRepository; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class BridgeClientRepositoryTest extends TestCase { + use MockeryPHPUnitIntegration; + /** * @var \Laravel\Passport\ClientRepository */ diff --git a/tests/Unit/BridgeRefreshTokenRepositoryTest.php b/tests/Unit/BridgeRefreshTokenRepositoryTest.php index 2fc90957..13940632 100644 --- a/tests/Unit/BridgeRefreshTokenRepositoryTest.php +++ b/tests/Unit/BridgeRefreshTokenRepositoryTest.php @@ -9,15 +9,13 @@ use Laravel\Passport\Bridge\RefreshToken; use Laravel\Passport\Bridge\RefreshTokenRepository as BridgeRefreshTokenRepository; use Laravel\Passport\RefreshTokenRepository; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class BridgeRefreshTokenRepositoryTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_access_tokens_can_be_persisted() { diff --git a/tests/Unit/BridgeScopeRepositoryTest.php b/tests/Unit/BridgeScopeRepositoryTest.php index 8b204935..aa8acfc9 100644 --- a/tests/Unit/BridgeScopeRepositoryTest.php +++ b/tests/Unit/BridgeScopeRepositoryTest.php @@ -8,11 +8,14 @@ use Laravel\Passport\Client as ClientModel; use Laravel\Passport\ClientRepository; use Laravel\Passport\Passport; -use Mockery; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; +use Mockery as m; use PHPUnit\Framework\TestCase; class BridgeScopeRepositoryTest extends TestCase { + use MockeryPHPUnitIntegration; + protected function tearDown(): void { Passport::$withInheritedScopes = false; @@ -24,9 +27,9 @@ public function test_invalid_scopes_are_removed() 'scope-1' => 'description', ]); - $client = Mockery::mock(ClientModel::class)->makePartial(); + $client = m::mock(ClientModel::class)->makePartial(); - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive')->withAnyArgs()->andReturn($client); $repository = new ScopeRepository($clients); @@ -44,10 +47,10 @@ public function test_invalid_scopes_are_removed_without_a_client_repository() 'scope-1' => 'description', ]); - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive') ->with('id') - ->andReturn(Mockery::mock(ClientModel::class)->makePartial()); + ->andReturn(m::mock(ClientModel::class)->makePartial()); $repository = new ScopeRepository($clients); @@ -65,10 +68,10 @@ public function test_clients_do_not_restrict_scopes_by_default() 'scope-2' => 'description', ]); - $client = Mockery::mock(ClientModel::class)->makePartial(); + $client = m::mock(ClientModel::class)->makePartial(); $client->scopes = null; - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive')->withAnyArgs()->andReturn($client); $repository = new ScopeRepository($clients); @@ -87,10 +90,10 @@ public function test_scopes_disallowed_for_client_are_removed() 'scope-2' => 'description', ]); - $client = Mockery::mock(ClientModel::class)->makePartial(); + $client = m::mock(ClientModel::class)->makePartial(); $client->scopes = ['scope-1']; - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive')->withAnyArgs()->andReturn($client); $repository = new ScopeRepository($clients); @@ -112,10 +115,10 @@ public function test_scopes_disallowed_for_client_are_removed_but_inherited_scop 'scope-2' => 'description', ]); - $client = Mockery::mock(ClientModel::class)->makePartial(); + $client = m::mock(ClientModel::class)->makePartial(); $client->scopes = ['scope-1']; - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive')->withAnyArgs()->andReturn($client); $repository = new ScopeRepository($clients); @@ -133,9 +136,9 @@ public function test_superuser_scope_cant_be_applied_if_wrong_grant() 'scope-1' => 'description', ]); - $client = Mockery::mock(ClientModel::class)->makePartial(); + $client = m::mock(ClientModel::class)->makePartial(); - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive')->withAnyArgs()->andReturn($client); $repository = new ScopeRepository($clients); @@ -153,10 +156,10 @@ public function test_superuser_scope_cant_be_applied_if_wrong_grant_without_a_cl 'scope-1' => 'description', ]); - $clients = Mockery::mock(ClientRepository::class); + $clients = m::mock(ClientRepository::class); $clients->shouldReceive('findActive') ->with('id') - ->andReturn(Mockery::mock(ClientModel::class)->makePartial()); + ->andReturn(m::mock(ClientModel::class)->makePartial()); $repository = new ScopeRepository($clients); diff --git a/tests/Unit/CheckClientCredentialsForAnyScopeTest.php b/tests/Unit/CheckClientCredentialsForAnyScopeTest.php index 5131cfc8..5cb6b570 100644 --- a/tests/Unit/CheckClientCredentialsForAnyScopeTest.php +++ b/tests/Unit/CheckClientCredentialsForAnyScopeTest.php @@ -7,16 +7,14 @@ use Laravel\Passport\Http\Middleware\CheckClientCredentialsForAnyScope; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\ResourceServer; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; class CheckClientCredentialsForAnyScopeTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_request_is_passed_along_if_token_is_valid() { diff --git a/tests/Unit/CheckClientCredentialsTest.php b/tests/Unit/CheckClientCredentialsTest.php index 1c89404e..0fe7b690 100644 --- a/tests/Unit/CheckClientCredentialsTest.php +++ b/tests/Unit/CheckClientCredentialsTest.php @@ -7,16 +7,14 @@ use Laravel\Passport\Http\Middleware\CheckClientCredentials; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\ResourceServer; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; class CheckClientCredentialsTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_request_is_passed_along_if_token_is_valid() { diff --git a/tests/Unit/CheckForAnyScopeTest.php b/tests/Unit/CheckForAnyScopeTest.php index e567feeb..b4937bf7 100644 --- a/tests/Unit/CheckForAnyScopeTest.php +++ b/tests/Unit/CheckForAnyScopeTest.php @@ -4,15 +4,13 @@ use Laravel\Passport\Exceptions\AuthenticationException; use Laravel\Passport\Http\Middleware\CheckForAnyScope as CheckScopes; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class CheckForAnyScopeTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_request_is_passed_along_if_scopes_are_present_on_token() { diff --git a/tests/Unit/CheckScopesTest.php b/tests/Unit/CheckScopesTest.php index 21e8b40b..cc75b013 100644 --- a/tests/Unit/CheckScopesTest.php +++ b/tests/Unit/CheckScopesTest.php @@ -4,15 +4,13 @@ use Laravel\Passport\Exceptions\AuthenticationException; use Laravel\Passport\Http\Middleware\CheckScopes; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class CheckScopesTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_request_is_passed_along_if_scopes_are_present_on_token() { diff --git a/tests/Unit/ClientControllerTest.php b/tests/Unit/ClientControllerTest.php index 66eba0c3..9d360f17 100644 --- a/tests/Unit/ClientControllerTest.php +++ b/tests/Unit/ClientControllerTest.php @@ -8,16 +8,14 @@ use Laravel\Passport\ClientRepository; use Laravel\Passport\Http\Controllers\ClientController; use Laravel\Passport\Http\Rules\RedirectRule; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response; class ClientControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_all_the_clients_for_the_current_user_can_be_retrieved() { diff --git a/tests/Unit/CreateFreshApiTokenTest.php b/tests/Unit/CreateFreshApiTokenTest.php index 026b1151..bf0b5103 100644 --- a/tests/Unit/CreateFreshApiTokenTest.php +++ b/tests/Unit/CreateFreshApiTokenTest.php @@ -7,16 +7,14 @@ use Laravel\Passport\ApiTokenCookieFactory; use Laravel\Passport\Http\Middleware\CreateFreshApiToken; use Laravel\Passport\Passport; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Cookie; class CreateFreshApiTokenTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function testShouldReceiveAFreshToken() { diff --git a/tests/Unit/DenyAuthorizationControllerTest.php b/tests/Unit/DenyAuthorizationControllerTest.php index ac4474b2..843e31b0 100644 --- a/tests/Unit/DenyAuthorizationControllerTest.php +++ b/tests/Unit/DenyAuthorizationControllerTest.php @@ -6,16 +6,14 @@ use Laravel\Passport\Http\Controllers\DenyAuthorizationController; use League\OAuth2\Server\AuthorizationServer; use League\OAuth2\Server\RequestTypes\AuthorizationRequest; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; class DenyAuthorizationControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_authorization_can_be_denied() { diff --git a/tests/Unit/HandlesOAuthErrorsTest.php b/tests/Unit/HandlesOAuthErrorsTest.php index 20479f7c..ca64a5c6 100644 --- a/tests/Unit/HandlesOAuthErrorsTest.php +++ b/tests/Unit/HandlesOAuthErrorsTest.php @@ -6,17 +6,11 @@ use Laravel\Passport\Exceptions\OAuthServerException; use Laravel\Passport\Http\Controllers\HandlesOAuthErrors; use League\OAuth2\Server\Exception\OAuthServerException as LeagueException; -use Mockery as m; use PHPUnit\Framework\TestCase; use RuntimeException; class HandlesOAuthErrorsTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } - public function testShouldReturnCallbackResultIfNoErrorIsThrown() { $controller = new HandlesOAuthErrorsStubController; diff --git a/tests/Unit/HasApiTokensTest.php b/tests/Unit/HasApiTokensTest.php index 86c398d0..8c819c8a 100644 --- a/tests/Unit/HasApiTokensTest.php +++ b/tests/Unit/HasApiTokensTest.php @@ -5,14 +5,16 @@ use Illuminate\Container\Container; use Laravel\Passport\AccessToken; use Laravel\Passport\HasApiTokens; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class HasApiTokensTest extends TestCase { + use MockeryPHPUnitIntegration; + protected function tearDown(): void { - m::close(); Container::getInstance()->flush(); } diff --git a/tests/Unit/PassportServiceProviderTest.php b/tests/Unit/PassportServiceProviderTest.php index f57242cc..f4ad5459 100644 --- a/tests/Unit/PassportServiceProviderTest.php +++ b/tests/Unit/PassportServiceProviderTest.php @@ -6,15 +6,16 @@ use Illuminate\Contracts\Foundation\Application as App; use Laravel\Passport\Passport; use Laravel\Passport\PassportServiceProvider; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class PassportServiceProviderTest extends TestCase { + use MockeryPHPUnitIntegration; + protected function tearDown(): void { - parent::tearDown(); - @unlink(__DIR__.'/../keys/oauth-private.key'); } diff --git a/tests/Unit/PersonalAccessTokenControllerTest.php b/tests/Unit/PersonalAccessTokenControllerTest.php index 0302c7d7..49638825 100644 --- a/tests/Unit/PersonalAccessTokenControllerTest.php +++ b/tests/Unit/PersonalAccessTokenControllerTest.php @@ -9,16 +9,14 @@ use Laravel\Passport\Passport; use Laravel\Passport\Token; use Laravel\Passport\TokenRepository; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Response; class PersonalAccessTokenControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_tokens_can_be_retrieved_for_users() { diff --git a/tests/Unit/RedirectRuleTest.php b/tests/Unit/RedirectRuleTest.php index e4c22656..d5cf8bba 100644 --- a/tests/Unit/RedirectRuleTest.php +++ b/tests/Unit/RedirectRuleTest.php @@ -5,15 +5,13 @@ use Illuminate\Contracts\Validation\Factory; use Illuminate\Contracts\Validation\Validator; use Laravel\Passport\Http\Rules\RedirectRule; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; class RedirectRuleTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_it_passes_with_a_single_valid_url() { diff --git a/tests/Unit/TokenGuardTest.php b/tests/Unit/TokenGuardTest.php index d9a0513e..d68bbed4 100644 --- a/tests/Unit/TokenGuardTest.php +++ b/tests/Unit/TokenGuardTest.php @@ -19,15 +19,17 @@ use Laravel\Passport\PassportUserProvider; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\ResourceServer; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ServerRequestInterface; class TokenGuardTest extends TestCase { + use MockeryPHPUnitIntegration; + protected function tearDown(): void { - m::close(); Container::getInstance()->flush(); } diff --git a/tests/Unit/TransientTokenControllerTest.php b/tests/Unit/TransientTokenControllerTest.php index 0ebb1ab8..e148e4b7 100644 --- a/tests/Unit/TransientTokenControllerTest.php +++ b/tests/Unit/TransientTokenControllerTest.php @@ -5,16 +5,14 @@ use Illuminate\Http\Request; use Laravel\Passport\ApiTokenCookieFactory; use Laravel\Passport\Http\Controllers\TransientTokenController; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Cookie; class TransientTokenControllerTest extends TestCase { - protected function tearDown(): void - { - m::close(); - } + use MockeryPHPUnitIntegration; public function test_token_can_be_refreshed() {