Skip to content

Commit 11d95f5

Browse files
authored
Using assertSame to make assertion equals strict (#1343)
1 parent ffcb546 commit 11d95f5

16 files changed

+36
-36
lines changed

tests/Unit/AccessTokenControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function test_a_token_can_be_issued()
3838

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

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

4444
public function test_exceptions_are_handled()

tests/Unit/ApproveAuthorizationControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function test_complete_authorization_request()
4949
->with($authRequest, m::type(ResponseInterface::class))
5050
->andReturn($psrResponse);
5151

52-
$this->assertEquals('response', $controller->approve($request)->getContent());
52+
$this->assertSame('response', $controller->approve($request)->getContent());
5353
}
5454
}
5555

tests/Unit/AuthorizationControllerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@ public function test_authorization_view_is_presented()
5656
$client->shouldReceive('skipsAuthorization')->andReturn(false);
5757

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

6464
return 'view';
6565
});
6666

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

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

134-
$this->assertEquals('approved', $controller->authorize(
134+
$this->assertSame('approved', $controller->authorize(
135135
m::mock(ServerRequestInterface::class), $request, $clients, $tokens
136136
)->getContent());
137137
}
@@ -174,7 +174,7 @@ public function test_request_is_approved_if_client_can_skip_authorization()
174174
->with($user, $client)
175175
->andReturnNull();
176176

177-
$this->assertEquals('approved', $controller->authorize(
177+
$this->assertSame('approved', $controller->authorize(
178178
m::mock(ServerRequestInterface::class), $request, $clients, $tokens
179179
)->getContent());
180180
}

tests/Unit/AuthorizedAccessTokenControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function test_tokens_can_be_deleted()
9696

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

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

102102
public function test_not_found_response_is_returned_if_user_doesnt_have_token()
@@ -112,6 +112,6 @@ public function test_not_found_response_is_returned_if_user_doesnt_have_token()
112112
return $user;
113113
});
114114

115-
$this->assertEquals(404, $this->controller->destroy($request, 3)->status());
115+
$this->assertSame(404, $this->controller->destroy($request, 3)->status());
116116
}
117117
}

tests/Unit/BridgeAccessTokenRepositoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public function test_access_tokens_can_be_persisted()
2727
$events = m::mock(Dispatcher::class);
2828

2929
$tokenRepository->shouldReceive('create')->once()->andReturnUsing(function ($array) use ($expiration) {
30-
$this->assertEquals(1, $array['id']);
31-
$this->assertEquals(2, $array['user_id']);
32-
$this->assertEquals('client-id', $array['client_id']);
30+
$this->assertSame(1, $array['id']);
31+
$this->assertSame(2, $array['user_id']);
32+
$this->assertSame('client-id', $array['client_id']);
3333
$this->assertEquals(['scopes'], $array['scopes']);
3434
$this->assertEquals(false, $array['revoked']);
3535
$this->assertInstanceOf('DateTime', $array['created_at']);
@@ -62,6 +62,6 @@ public function test_can_get_new_access_token()
6262
$this->assertInstanceOf(AccessToken::class, $token);
6363
$this->assertEquals($client, $token->getClient());
6464
$this->assertEquals($scopes, $token->getScopes());
65-
$this->assertEquals($userIdentifier, $token->getUserIdentifier());
65+
$this->assertSame($userIdentifier, $token->getUserIdentifier());
6666
}
6767
}

tests/Unit/BridgeClientRepositoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function test_can_get_client()
4646
$client = $this->repository->getClientEntity(1);
4747

4848
$this->assertInstanceOf(Client::class, $client);
49-
$this->assertEquals('1', $client->getIdentifier());
50-
$this->assertEquals('Client', $client->getName());
49+
$this->assertSame('1', $client->getIdentifier());
50+
$this->assertSame('Client', $client->getName());
5151
$this->assertEquals(['http://localhost'], $client->getRedirectUri());
5252
$this->assertTrue($client->isConfidential());
5353
}

tests/Unit/CheckClientCredentialsForAnyScopeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function test_request_is_passed_along_if_token_is_valid()
4747
return 'response';
4848
});
4949

50-
$this->assertEquals('response', $response);
50+
$this->assertSame('response', $response);
5151
}
5252

5353
public function test_request_is_passed_along_if_token_has_any_required_scope()
@@ -80,7 +80,7 @@ public function test_request_is_passed_along_if_token_has_any_required_scope()
8080
return 'response';
8181
}, 'notfoo', 'bar', 'notbaz');
8282

83-
$this->assertEquals('response', $response);
83+
$this->assertSame('response', $response);
8484
}
8585

8686
public function test_exception_is_thrown_when_oauth_throws_exception()

tests/Unit/CheckClientCredentialsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function test_request_is_passed_along_if_token_is_valid()
4747
return 'response';
4848
});
4949

50-
$this->assertEquals('response', $response);
50+
$this->assertSame('response', $response);
5151
}
5252

5353
public function test_request_is_passed_along_if_token_and_scope_are_valid()
@@ -79,7 +79,7 @@ public function test_request_is_passed_along_if_token_and_scope_are_valid()
7979
return 'response';
8080
}, 'see-profile');
8181

82-
$this->assertEquals('response', $response);
82+
$this->assertSame('response', $response);
8383
}
8484

8585
public function test_exception_is_thrown_when_oauth_throws_exception()

tests/Unit/CheckForAnyScopeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function test_request_is_passed_along_if_scopes_are_present_on_token()
2626
return 'response';
2727
}, 'foo', 'bar');
2828

29-
$this->assertEquals('response', $response);
29+
$this->assertSame('response', $response);
3030
}
3131

3232
public function test_exception_is_thrown_if_token_doesnt_have_scope()

tests/Unit/CheckScopesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function test_request_is_passed_along_if_scopes_are_present_on_token()
2626
return 'response';
2727
}, 'foo', 'bar');
2828

29-
$this->assertEquals('response', $response);
29+
$this->assertSame('response', $response);
3030
}
3131

3232
public function test_exception_is_thrown_if_token_doesnt_have_scope()

0 commit comments

Comments
 (0)