Skip to content

Using assertSame to make assertion equals strict #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 tests/Unit/AccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function test_a_token_can_be_issued()

$controller = new AccessTokenController($server, $tokens, $jwt);

$this->assertEquals('{"access_token":"access-token"}', $controller->issueToken($request)->getContent());
$this->assertSame('{"access_token":"access-token"}', $controller->issueToken($request)->getContent());
}

public function test_exceptions_are_handled()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ApproveAuthorizationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function test_complete_authorization_request()
->with($authRequest, m::type(ResponseInterface::class))
->andReturn($psrResponse);

$this->assertEquals('response', $controller->approve($request)->getContent());
$this->assertSame('response', $controller->approve($request)->getContent());
}
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/AuthorizationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ public function test_authorization_view_is_presented()
$client->shouldReceive('skipsAuthorization')->andReturn(false);

$response->shouldReceive('view')->once()->andReturnUsing(function ($view, $data) use ($client, $user) {
$this->assertEquals('passport::authorize', $view);
$this->assertSame('passport::authorize', $view);
$this->assertEquals($client, $data['client']);
$this->assertEquals($user, $data['user']);
$this->assertEquals('description', $data['scopes'][0]->description);
$this->assertSame('description', $data['scopes'][0]->description);

return 'view';
});

$tokens = m::mock(TokenRepository::class);
$tokens->shouldReceive('findValidToken')->with($user, $client)->andReturnNull();

$this->assertEquals('view', $controller->authorize(
$this->assertSame('view', $controller->authorize(
m::mock(ServerRequestInterface::class), $request, $clients, $tokens
));
}
Expand Down Expand Up @@ -131,7 +131,7 @@ public function test_request_is_approved_if_valid_token_exists()
->andReturn($token = m::mock(Token::class));
$token->shouldReceive('getAttribute')->with('scopes')->andReturn(['scope-1']);

$this->assertEquals('approved', $controller->authorize(
$this->assertSame('approved', $controller->authorize(
m::mock(ServerRequestInterface::class), $request, $clients, $tokens
)->getContent());
}
Expand Down Expand Up @@ -174,7 +174,7 @@ public function test_request_is_approved_if_client_can_skip_authorization()
->with($user, $client)
->andReturnNull();

$this->assertEquals('approved', $controller->authorize(
$this->assertSame('approved', $controller->authorize(
m::mock(ServerRequestInterface::class), $request, $clients, $tokens
)->getContent());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/AuthorizedAccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function test_tokens_can_be_deleted()

$response = $this->controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
$this->assertSame(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_not_found_response_is_returned_if_user_doesnt_have_token()
Expand All @@ -112,6 +112,6 @@ public function test_not_found_response_is_returned_if_user_doesnt_have_token()
return $user;
});

$this->assertEquals(404, $this->controller->destroy($request, 3)->status());
$this->assertSame(404, $this->controller->destroy($request, 3)->status());
}
}
8 changes: 4 additions & 4 deletions tests/Unit/BridgeAccessTokenRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function test_access_tokens_can_be_persisted()
$events = m::mock(Dispatcher::class);

$tokenRepository->shouldReceive('create')->once()->andReturnUsing(function ($array) use ($expiration) {
$this->assertEquals(1, $array['id']);
$this->assertEquals(2, $array['user_id']);
$this->assertEquals('client-id', $array['client_id']);
$this->assertSame(1, $array['id']);
$this->assertSame(2, $array['user_id']);
$this->assertSame('client-id', $array['client_id']);
$this->assertEquals(['scopes'], $array['scopes']);
$this->assertEquals(false, $array['revoked']);
$this->assertInstanceOf('DateTime', $array['created_at']);
Expand Down Expand Up @@ -62,6 +62,6 @@ public function test_can_get_new_access_token()
$this->assertInstanceOf(AccessToken::class, $token);
$this->assertEquals($client, $token->getClient());
$this->assertEquals($scopes, $token->getScopes());
$this->assertEquals($userIdentifier, $token->getUserIdentifier());
$this->assertSame($userIdentifier, $token->getUserIdentifier());
}
}
4 changes: 2 additions & 2 deletions tests/Unit/BridgeClientRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function test_can_get_client()
$client = $this->repository->getClientEntity(1);

$this->assertInstanceOf(Client::class, $client);
$this->assertEquals('1', $client->getIdentifier());
$this->assertEquals('Client', $client->getName());
$this->assertSame('1', $client->getIdentifier());
$this->assertSame('Client', $client->getName());
$this->assertEquals(['http://localhost'], $client->getRedirectUri());
$this->assertTrue($client->isConfidential());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/CheckClientCredentialsForAnyScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_request_is_passed_along_if_token_is_valid()
return 'response';
});

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_request_is_passed_along_if_token_has_any_required_scope()
Expand Down Expand Up @@ -80,7 +80,7 @@ public function test_request_is_passed_along_if_token_has_any_required_scope()
return 'response';
}, 'notfoo', 'bar', 'notbaz');

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_exception_is_thrown_when_oauth_throws_exception()
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/CheckClientCredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_request_is_passed_along_if_token_is_valid()
return 'response';
});

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_request_is_passed_along_if_token_and_scope_are_valid()
Expand Down Expand Up @@ -79,7 +79,7 @@ public function test_request_is_passed_along_if_token_and_scope_are_valid()
return 'response';
}, 'see-profile');

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_exception_is_thrown_when_oauth_throws_exception()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CheckForAnyScopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_request_is_passed_along_if_scopes_are_present_on_token()
return 'response';
}, 'foo', 'bar');

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_exception_is_thrown_if_token_doesnt_have_scope()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CheckScopesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function test_request_is_passed_along_if_scopes_are_present_on_token()
return 'response';
}, 'foo', 'bar');

$this->assertEquals('response', $response);
$this->assertSame('response', $response);
}

public function test_exception_is_thrown_if_token_doesnt_have_scope()
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/ClientControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function test_clients_can_be_updated()
$clients, $validator, $redirectRule
);

$this->assertEquals('response', $controller->update($request, 1));
$this->assertSame('response', $controller->update($request, 1));
}

public function test_404_response_if_client_doesnt_belong_to_user()
Expand All @@ -170,7 +170,7 @@ public function test_404_response_if_client_doesnt_belong_to_user()
$clients, $validator, m::mock(RedirectRule::class)
);

$this->assertEquals(404, $controller->update($request, 1)->status());
$this->assertSame(404, $controller->update($request, 1)->status());
}

public function test_clients_can_be_deleted()
Expand Down Expand Up @@ -200,7 +200,7 @@ public function test_clients_can_be_deleted()

$response = $controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
$this->assertSame(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_404_response_if_client_doesnt_belong_to_user_on_delete()
Expand All @@ -225,7 +225,7 @@ public function test_404_response_if_client_doesnt_belong_to_user_on_delete()
$clients, $validator, m::mock(RedirectRule::class)
);

$this->assertEquals(404, $controller->destroy($request, 1)->status());
$this->assertSame(404, $controller->destroy($request, 1)->status());
}
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/DenyAuthorizationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function test_authorization_can_be_denied()
return $url;
});

$this->assertEquals('http://localhost?error=access_denied&state=state', $controller->deny($request));
$this->assertSame('http://localhost?error=access_denied&state=state', $controller->deny($request));
}

public function test_authorization_can_be_denied_with_multiple_redirect_uris()
Expand Down Expand Up @@ -77,7 +77,7 @@ public function test_authorization_can_be_denied_with_multiple_redirect_uris()
return $url;
});

$this->assertEquals('http://localhost?error=access_denied&state=state', $controller->deny($request));
$this->assertSame('http://localhost?error=access_denied&state=state', $controller->deny($request));
}

public function test_authorization_can_be_denied_implicit()
Expand Down Expand Up @@ -109,7 +109,7 @@ public function test_authorization_can_be_denied_implicit()
return $url;
});

$this->assertEquals('http://localhost#error=access_denied&state=state', $controller->deny($request));
$this->assertSame('http://localhost#error=access_denied&state=state', $controller->deny($request));
}

public function test_authorization_can_be_denied_with_existing_query_string()
Expand Down Expand Up @@ -141,7 +141,7 @@ public function test_authorization_can_be_denied_with_existing_query_string()
return $url;
});

$this->assertEquals('http://localhost?action=some_action&error=access_denied&state=state', $controller->deny($request));
$this->assertSame('http://localhost?action=some_action&error=access_denied&state=state', $controller->deny($request));
}

public function test_auth_request_should_exist()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/HandlesOAuthErrorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testShouldHandleOAuthServerException()
}

$this->assertInstanceOf(OAuthServerException::class, $e);
$this->assertEquals('Error', $e->getMessage());
$this->assertSame('Error', $e->getMessage());
$this->assertInstanceOf(LeagueException::class, $e->getPrevious());

$response = $e->render(new Request);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/PassportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test_scopes_can_be_managed()

$this->assertTrue(Passport::hasScope('user'));
$this->assertEquals(['user'], Passport::scopeIds());
$this->assertEquals('user', Passport::scopes()[0]->id);
$this->assertSame('user', Passport::scopes()[0]->id);
}

public function test_auth_code_instance_can_be_created()
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/PersonalAccessTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function test_tokens_can_be_updated()
$tokenRepository = m::mock(TokenRepository::class);
$controller = new PersonalAccessTokenController($tokenRepository, $validator);

$this->assertEquals('response', $controller->store($request));
$this->assertSame('response', $controller->store($request));
}

public function test_tokens_can_be_deleted()
Expand All @@ -108,7 +108,7 @@ public function test_tokens_can_be_deleted()

$response = $controller->destroy($request, 1);

$this->assertEquals(Response::HTTP_NO_CONTENT, $response->status());
$this->assertSame(Response::HTTP_NO_CONTENT, $response->status());
}

public function test_not_found_response_is_returned_if_user_doesnt_have_token()
Expand All @@ -128,6 +128,6 @@ public function test_not_found_response_is_returned_if_user_doesnt_have_token()
$validator = m::mock(Factory::class);
$controller = new PersonalAccessTokenController($tokenRepository, $validator);

$this->assertEquals(404, $controller->destroy($request, 3)->status());
$this->assertSame(404, $controller->destroy($request, 3)->status());
}
}
4 changes: 2 additions & 2 deletions tests/Unit/TransientTokenControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function test_token_can_be_refreshed()

$response = $controller->refresh($request);

$this->assertEquals(200, $response->status());
$this->assertEquals('Refreshed.', $response->getOriginalContent());
$this->assertSame(200, $response->status());
$this->assertSame('Refreshed.', $response->getOriginalContent());
}
}