From eae1535ad79ef753f0e2f439d186e3957977e1ca Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Wed, 6 Jul 2016 23:19:36 +0200 Subject: [PATCH] Use stricter tests assertions. --- tests/Auth/AuthTest.php | 6 +- tests/Auth/Provider/BasicTest.php | 2 +- tests/Auth/Provider/JWTTest.php | 4 +- tests/Auth/Provider/OAuth2Test.php | 4 +- tests/DispatcherTest.php | 76 +++++++++++----------- tests/Exception/HandlerTest.php | 32 +++++----- tests/Http/Middleware/AuthTest.php | 4 +- tests/Http/Middleware/RateLimitTest.php | 18 +++--- tests/Http/Middleware/RequestTest.php | 6 +- tests/Http/Parser/AcceptTest.php | 18 +++--- tests/Http/RateLimit/HandlerTest.php | 2 +- tests/Http/Response/FactoryTest.php | 34 +++++----- tests/Http/Response/Format/JsonTest.php | 16 ++--- tests/Http/Response/Format/JsonpTest.php | 12 ++-- tests/Http/ResponseTest.php | 10 +-- tests/Routing/Adapter/BaseAdapterTest.php | 36 +++++------ tests/Routing/RouteTest.php | 24 +++---- tests/Routing/RouterTest.php | 78 +++++++++++------------ tests/Transformer/FactoryTest.php | 14 ++-- 19 files changed, 199 insertions(+), 197 deletions(-) diff --git a/tests/Auth/AuthTest.php b/tests/Auth/AuthTest.php index a1bc5f1dc..d90485381 100644 --- a/tests/Auth/AuthTest.php +++ b/tests/Auth/AuthTest.php @@ -68,7 +68,7 @@ public function testAuthenticationIsSuccessfulAndUserIsSet() $user = $this->auth->authenticate(); - $this->assertEquals(1, $user->id); + $this->assertSame(1, $user->id); } public function testProvidersAreFilteredWhenSpecificProviderIsRequested() @@ -83,7 +83,7 @@ public function testProvidersAreFilteredWhenSpecificProviderIsRequested() $this->auth->extend('two', $provider); $this->auth->authenticate(['two']); - $this->assertEquals($provider, $this->auth->getProviderUsed()); + $this->assertSame($provider, $this->auth->getProviderUsed()); } public function testGettingUserWhenNotAuthenticatedAttemptsToAuthenticateAndReturnsNull() @@ -100,7 +100,7 @@ public function testGettingUserWhenAlreadyAuthenticatedReturnsUser() { $this->auth->setUser((object) ['id' => 1]); - $this->assertEquals(1, $this->auth->user()->id); + $this->assertSame(1, $this->auth->user()->id); $this->assertTrue($this->auth->check()); } } diff --git a/tests/Auth/Provider/BasicTest.php b/tests/Auth/Provider/BasicTest.php index 3076a4443..76f5caa4d 100644 --- a/tests/Auth/Provider/BasicTest.php +++ b/tests/Auth/Provider/BasicTest.php @@ -40,6 +40,6 @@ public function testValidCredentialsReturnsUser() $this->auth->shouldReceive('onceBasic')->once()->with('email')->andReturn(null); $this->auth->shouldReceive('user')->once()->andReturn('foo'); - $this->assertEquals('foo', $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))); + $this->assertSame('foo', $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))); } } diff --git a/tests/Auth/Provider/JWTTest.php b/tests/Auth/Provider/JWTTest.php index 7160a0cbe..fbe028963 100644 --- a/tests/Auth/Provider/JWTTest.php +++ b/tests/Auth/Provider/JWTTest.php @@ -52,7 +52,7 @@ public function testAuthenticatingSucceedsAndReturnsUserObject() $this->auth->shouldReceive('setToken')->with('foo')->andReturn(m::self()); $this->auth->shouldReceive('authenticate')->once()->andReturn((object) ['id' => 1]); - $this->assertEquals(1, $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))->id); + $this->assertSame(1, $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))->id); } public function testAuthenticatingWithQueryStringSucceedsAndReturnsUserObject() @@ -62,6 +62,6 @@ public function testAuthenticatingWithQueryStringSucceedsAndReturnsUserObject() $this->auth->shouldReceive('setToken')->with('foo')->andReturn(m::self()); $this->auth->shouldReceive('authenticate')->once()->andReturn((object) ['id' => 1]); - $this->assertEquals(1, $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))->id); + $this->assertSame(1, $this->provider->authenticate($request, m::mock('Dingo\Api\Routing\Route'))->id); } } diff --git a/tests/Auth/Provider/OAuth2Test.php b/tests/Auth/Provider/OAuth2Test.php index fccc87ae6..b48adf217 100644 --- a/tests/Auth/Provider/OAuth2Test.php +++ b/tests/Auth/Provider/OAuth2Test.php @@ -116,7 +116,7 @@ public function testClientIsResolved() $route->shouldReceive('scopes')->once()->andReturn([]); $route->shouldReceive('scopeStrict')->once()->andReturn(false); - $this->assertEquals('foo', $this->provider->authenticate($request, $route)); + $this->assertSame('foo', $this->provider->authenticate($request, $route)); } public function testUserIsResolved() @@ -142,6 +142,6 @@ public function testUserIsResolved() $route->shouldReceive('scopes')->once()->andReturn([]); $route->shouldReceive('scopeStrict')->once()->andReturn(false); - $this->assertEquals('foo', $this->provider->authenticate($request, $route)); + $this->assertSame('foo', $this->provider->authenticate($request, $route)); } } diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php index eb06e4083..64c238fe0 100644 --- a/tests/DispatcherTest.php +++ b/tests/DispatcherTest.php @@ -78,20 +78,22 @@ public function testInternalRequests() }); }); - $this->assertEquals('foo', $this->dispatcher->get('test')); - $this->assertEquals('bar', $this->dispatcher->post('test')); - $this->assertEquals('baz', $this->dispatcher->put('test')); - $this->assertEquals('yin', $this->dispatcher->patch('test')); - $this->assertEquals('yang', $this->dispatcher->delete('test')); + $this->assertSame('foo', $this->dispatcher->get('test')); + $this->assertSame('bar', $this->dispatcher->post('test')); + $this->assertSame('baz', $this->dispatcher->put('test')); + $this->assertSame('yin', $this->dispatcher->patch('test')); + $this->assertSame('yang', $this->dispatcher->delete('test')); } public function testInternalRequestWithVersionAndParameters() { $this->router->version('v1', function () { - $this->router->get('test', function () { return 'test'; }); + $this->router->get('test', function () { + return 'test'; + }); }); - $this->assertEquals('test', $this->dispatcher->version('v1')->with(['foo' => 'bar'])->get('test')); + $this->assertSame('test', $this->dispatcher->version('v1')->with(['foo' => 'bar'])->get('test')); } public function testInternalRequestWithPrefix() @@ -102,11 +104,11 @@ public function testInternalRequestWithPrefix() }); }); - $this->assertEquals('test', $this->dispatcher->get('baz/test')); + $this->assertSame('test', $this->dispatcher->get('baz/test')); $this->dispatcher->setPrefix('baz'); - $this->assertEquals('test', $this->dispatcher->get('test')); + $this->assertSame('test', $this->dispatcher->get('test')); } public function testInternalRequestWithDomain() @@ -117,11 +119,11 @@ public function testInternalRequestWithDomain() }); }); - $this->assertEquals('test', $this->dispatcher->get('http://foo.bar/test')); + $this->assertSame('test', $this->dispatcher->get('http://foo.bar/test')); $this->dispatcher->setDefaultDomain('foo.bar'); - $this->assertEquals('test', $this->dispatcher->get('test')); + $this->assertSame('test', $this->dispatcher->get('test')); } /** @@ -150,7 +152,7 @@ public function testInternalExceptionContainsResponseObject() $this->dispatcher->get('test'); } catch (InternalHttpException $exception) { $this->assertInstanceOf('Illuminate\Http\Response', $exception->getResponse()); - $this->assertEquals('test', $exception->getResponse()->getContent()); + $this->assertSame('test', $exception->getResponse()->getContent()); } } @@ -179,7 +181,7 @@ public function testPretendingToBeUserForSingleRequest() $this->router->version('v1', function () use ($user) { $this->router->get('test', function () use ($user) { - $this->assertEquals($user, $this->auth->user()); + $this->assertSame($user, $this->auth->user()); }); }); @@ -200,9 +202,9 @@ public function testInternalRequestWithMultipleVersionsCallsCorrectVersion() }); }); - $this->assertEquals('foo', $this->dispatcher->version('v1')->get('foo')); - $this->assertEquals('bar', $this->dispatcher->version('v2')->get('foo')); - $this->assertEquals('bar', $this->dispatcher->version('v3')->get('foo')); + $this->assertSame('foo', $this->dispatcher->version('v1')->get('foo')); + $this->assertSame('bar', $this->dispatcher->version('v2')->get('foo')); + $this->assertSame('bar', $this->dispatcher->version('v3')->get('foo')); } public function testInternalRequestWithNestedInternalRequest() @@ -225,26 +227,26 @@ public function testInternalRequestWithNestedInternalRequest() }); }); - $this->assertEquals('foobarbaz', $this->dispatcher->get('foo')); + $this->assertSame('foobarbaz', $this->dispatcher->get('foo')); } public function testRequestStackIsMaintained() { $this->router->version('v1', ['prefix' => 'api'], function () { $this->router->post('foo', function () { - $this->assertEquals('bar', $this->router->getCurrentRequest()->input('foo')); + $this->assertSame('bar', $this->router->getCurrentRequest()->input('foo')); $this->dispatcher->with(['foo' => 'baz'])->post('api/bar'); - $this->assertEquals('bar', $this->router->getCurrentRequest()->input('foo')); + $this->assertSame('bar', $this->router->getCurrentRequest()->input('foo')); }); $this->router->post('bar', function () { - $this->assertEquals('baz', $this->router->getCurrentRequest()->input('foo')); + $this->assertSame('baz', $this->router->getCurrentRequest()->input('foo')); $this->dispatcher->with(['foo' => 'bazinga'])->post('api/baz'); - $this->assertEquals('baz', $this->router->getCurrentRequest()->input('foo')); + $this->assertSame('baz', $this->router->getCurrentRequest()->input('foo')); }); $this->router->post('baz', function () { - $this->assertEquals('bazinga', $this->router->getCurrentRequest()->input('foo')); + $this->assertSame('bazinga', $this->router->getCurrentRequest()->input('foo')); }); }); @@ -255,19 +257,19 @@ public function testRouteStackIsMaintained() { $this->router->version('v1', function () { $this->router->post('foo', ['as' => 'foo', function () { - $this->assertEquals('foo', $this->router->getCurrentRoute()->getName()); + $this->assertSame('foo', $this->router->getCurrentRoute()->getName()); $this->dispatcher->post('bar'); - $this->assertEquals('foo', $this->router->getCurrentRoute()->getName()); + $this->assertSame('foo', $this->router->getCurrentRoute()->getName()); }]); $this->router->post('bar', ['as' => 'bar', function () { - $this->assertEquals('bar', $this->router->getCurrentRoute()->getName()); + $this->assertSame('bar', $this->router->getCurrentRoute()->getName()); $this->dispatcher->post('baz'); - $this->assertEquals('bar', $this->router->getCurrentRoute()->getName()); + $this->assertSame('bar', $this->router->getCurrentRoute()->getName()); }]); $this->router->post('baz', ['as' => 'bazinga', function () { - $this->assertEquals('bazinga', $this->router->getCurrentRoute()->getName()); + $this->assertSame('bazinga', $this->router->getCurrentRoute()->getName()); }]); }); @@ -278,11 +280,11 @@ public function testSendingJsonPayload() { $this->router->version('v1', function () { $this->router->post('foo', function () { - $this->assertEquals('jason', $this->router->getCurrentRequest()->json('username')); + $this->assertSame('jason', $this->router->getCurrentRequest()->json('username')); }); $this->router->post('bar', function () { - $this->assertEquals('mat', $this->router->getCurrentRequest()->json('username')); + $this->assertSame('mat', $this->router->getCurrentRequest()->json('username')); }); }); @@ -310,9 +312,9 @@ public function testInternalRequestsToDifferentDomains() }); }); - $this->assertEquals('v1 and v2 on domain foo.bar', $this->dispatcher->on('foo.bar')->version('v2')->get('foo')); - $this->assertEquals('v1 on domain foo.baz', $this->dispatcher->on('foo.baz')->get('foo')); - $this->assertEquals('v2 on domain foo.baz', $this->dispatcher->on('foo.baz')->version('v2')->get('foo')); + $this->assertSame('v1 and v2 on domain foo.bar', $this->dispatcher->on('foo.bar')->version('v2')->get('foo')); + $this->assertSame('v1 on domain foo.baz', $this->dispatcher->on('foo.baz')->get('foo')); + $this->assertSame('v2 on domain foo.baz', $this->dispatcher->on('foo.baz')->version('v2')->get('foo')); } public function testRequestingRawResponse() @@ -326,8 +328,8 @@ public function testRequestingRawResponse() $response = $this->dispatcher->raw()->get('foo'); $this->assertInstanceOf('Dingo\Api\Http\Response', $response); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); - $this->assertEquals(['foo' => 'bar'], $response->getOriginalContent()); + $this->assertSame('{"foo":"bar"}', $response->getContent()); + $this->assertSame(['foo' => 'bar'], $response->getOriginalContent()); } public function testRequestingRawResponseWithTransformers() @@ -345,8 +347,8 @@ public function testRequestingRawResponseWithTransformers() $response = $this->dispatcher->raw()->get('foo'); $this->assertInstanceOf('Dingo\Api\Http\Response', $response); - $this->assertEquals('{"name":"Jason"}', $response->getContent()); - $this->assertEquals($instance, $response->getOriginalContent()); + $this->assertSame('{"name":"Jason"}', $response->getContent()); + $this->assertSame($instance, $response->getOriginalContent()); } public function testUsingRequestFacadeDoesNotCacheRequestInstance() @@ -363,7 +365,7 @@ public function testUsingRequestFacadeDoesNotCacheRequestInstance() $response = $this->dispatcher->with(['foo' => 'bar'])->get('foo'); - $this->assertEquals('bar', $response); + $this->assertSame('bar', $response); $this->assertNull(RequestFacade::input('foo')); } } diff --git a/tests/Exception/HandlerTest.php b/tests/Exception/HandlerTest.php index 9b963b9ea..0f21f326a 100644 --- a/tests/Exception/HandlerTest.php +++ b/tests/Exception/HandlerTest.php @@ -48,8 +48,8 @@ public function testExceptionHandlerHandlesException() $response = $this->exceptionHandler->handle($exception); - $this->assertEquals('foo', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame('foo', $response->getContent()); + $this->assertSame(404, $response->getStatusCode()); } public function testExceptionHandlerHandlesExceptionAndCreatesNewResponse() @@ -63,8 +63,8 @@ public function testExceptionHandlerHandlesExceptionAndCreatesNewResponse() $response = $this->exceptionHandler->handle($exception); $this->assertInstanceOf('Illuminate\Http\Response', $response); - $this->assertEquals('foo', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame('foo', $response->getContent()); + $this->assertSame(404, $response->getStatusCode()); } public function testExceptionHandlerReturnsGenericWhenNoMatchingHandler() @@ -74,8 +74,8 @@ public function testExceptionHandlerReturnsGenericWhenNoMatchingHandler() $response = $this->exceptionHandler->handle($exception); $this->assertInstanceOf('Illuminate\Http\Response', $response); - $this->assertEquals('{"message":"bar","status_code":404}', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame('{"message":"bar","status_code":404}', $response->getContent()); + $this->assertSame(404, $response->getStatusCode()); } public function testUsingMultidimensionalArrayForGenericResponse() @@ -95,8 +95,8 @@ public function testUsingMultidimensionalArrayForGenericResponse() $response = $this->exceptionHandler->handle($exception); $this->assertInstanceOf('Illuminate\Http\Response', $response); - $this->assertEquals('{"error":{"message":"bar","status_code":404}}', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame('{"error":{"message":"bar","status_code":404}}', $response->getContent()); + $this->assertSame(404, $response->getStatusCode()); } public function testRegularExceptionsAreHandledByGenericHandler() @@ -105,8 +105,8 @@ public function testRegularExceptionsAreHandledByGenericHandler() $response = $this->exceptionHandler->handle($exception); - $this->assertEquals('{"message":"Uh oh","status_code":500}', $response->getContent()); - $this->assertEquals(500, $response->getStatusCode()); + $this->assertSame('{"message":"Uh oh","status_code":500}', $response->getContent()); + $this->assertSame(500, $response->getStatusCode()); } public function testResourceExceptionErrorsAreIncludedInResponse() @@ -116,8 +116,8 @@ public function testResourceExceptionErrorsAreIncludedInResponse() $response = $this->exceptionHandler->handle($exception); $this->assertInstanceOf('Illuminate\Http\Response', $response); - $this->assertEquals('{"message":"bar","errors":{"foo":["bar"]},"code":10,"status_code":422}', $response->getContent()); - $this->assertEquals(422, $response->getStatusCode()); + $this->assertSame('{"message":"bar","errors":{"foo":["bar"]},"code":10,"status_code":422}', $response->getContent()); + $this->assertSame(422, $response->getStatusCode()); } public function testExceptionTraceIncludedInResponse() @@ -140,8 +140,8 @@ public function testHttpExceptionsWithNoMessageUseStatusCodeMessage() $response = $this->exceptionHandler->handle($exception); $this->assertInstanceOf('Illuminate\Http\Response', $response); - $this->assertEquals('{"message":"404 Not Found","status_code":404}', $response->getContent()); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertSame('{"message":"404 Not Found","status_code":404}', $response->getContent()); + $this->assertSame(404, $response->getStatusCode()); } public function testExceptionsHandledByRenderAreReroutedThroughHandler() @@ -152,7 +152,7 @@ public function testExceptionsHandledByRenderAreReroutedThroughHandler() $response = $this->exceptionHandler->render($request, $exception); - $this->assertEquals('{"message":"404 Not Found","status_code":404}', $response->getContent()); + $this->assertSame('{"message":"404 Not Found","status_code":404}', $response->getContent()); } public function testSettingUserDefinedReplacements() @@ -164,6 +164,6 @@ public function testSettingUserDefinedReplacements() $response = $this->exceptionHandler->handle($exception); - $this->assertEquals('{"bing":"bar"}', $response->getContent()); + $this->assertSame('{"bing":"bar"}', $response->getContent()); } } diff --git a/tests/Http/Middleware/AuthTest.php b/tests/Http/Middleware/AuthTest.php index 66e546951..b82839926 100644 --- a/tests/Http/Middleware/AuthTest.php +++ b/tests/Http/Middleware/AuthTest.php @@ -39,7 +39,7 @@ public function testProtectedRouteFiresAuthenticationAndPasses() $this->router->shouldReceive('getCurrentRoute')->once()->andReturn($route); $this->middleware->handle($request, function ($handledRequest) use ($request) { - $this->assertEquals($handledRequest, $request); + $this->assertSame($handledRequest, $request); }); } @@ -59,7 +59,7 @@ public function testProtectedRouteAlreadyLoggedIn() $this->router->shouldReceive('getCurrentRoute')->once()->andReturn($route); $this->middleware->handle($request, function ($handledRequest) use ($request) { - $this->assertEquals($handledRequest, $request); + $this->assertSame($handledRequest, $request); }); } diff --git a/tests/Http/Middleware/RateLimitTest.php b/tests/Http/Middleware/RateLimitTest.php index baf5ad5fd..1e87319c0 100644 --- a/tests/Http/Middleware/RateLimitTest.php +++ b/tests/Http/Middleware/RateLimitTest.php @@ -53,7 +53,7 @@ public function testMiddlewareBypassesRequestsWithNoRateLimiting() return new Response('foo'); }); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); $this->assertArrayNotHasKey('x-ratelimit-limit', $response->headers->all()); $this->assertArrayNotHasKey('x-ratelimit-remaining', $response->headers->all()); $this->assertArrayNotHasKey('x-ratelimit-reset', $response->headers->all()); @@ -76,7 +76,7 @@ public function testMiddlewareBypassesInternalRequest() return new Response('foo'); }); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); $this->assertArrayNotHasKey('x-ratelimit-limit', $response->headers->all()); $this->assertArrayNotHasKey('x-ratelimit-remaining', $response->headers->all()); $this->assertArrayNotHasKey('x-ratelimit-reset', $response->headers->all()); @@ -99,7 +99,7 @@ public function testRateLimitingPassesAndResponseHeadersAreSet() return new Response('foo'); }); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); $this->assertArrayHasKey('x-ratelimit-limit', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-remaining', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-reset', $response->headers->all()); @@ -123,8 +123,8 @@ public function testRateLimitingFailsAndHeadersAreSetOnException() return new Response('foo'); }); } catch (HttpException $exception) { - $this->assertEquals(403, $exception->getStatusCode()); - $this->assertEquals('You have exceeded your rate limit.', $exception->getMessage()); + $this->assertSame(403, $exception->getStatusCode()); + $this->assertSame('You have exceeded your rate limit.', $exception->getMessage()); $this->assertArrayHasKey('X-RateLimit-Limit', $exception->getHeaders()); $this->assertArrayHasKey('X-RateLimit-Remaining', $exception->getHeaders()); $this->assertArrayHasKey('X-RateLimit-Reset', $exception->getHeaders()); @@ -149,8 +149,8 @@ public function testRateLimitingWithLimitsSetOnRoute() $this->assertArrayHasKey('x-ratelimit-limit', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-remaining', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-reset', $response->headers->all()); - $this->assertEquals(4, $response->headers->get('x-ratelimit-remaining')); - $this->assertEquals(5, $response->headers->get('x-ratelimit-limit')); + $this->assertSame(4, $response->headers->get('x-ratelimit-remaining')); + $this->assertSame(5, $response->headers->get('x-ratelimit-limit')); } public function testRateLimitingWithRouteThrottle() @@ -172,7 +172,7 @@ public function testRateLimitingWithRouteThrottle() $this->assertArrayHasKey('x-ratelimit-limit', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-remaining', $response->headers->all()); $this->assertArrayHasKey('x-ratelimit-reset', $response->headers->all()); - $this->assertEquals(9, $response->headers->get('x-ratelimit-remaining')); - $this->assertEquals(10, $response->headers->get('x-ratelimit-limit')); + $this->assertSame(9, $response->headers->get('x-ratelimit-remaining')); + $this->assertSame(10, $response->headers->get('x-ratelimit-limit')); } } diff --git a/tests/Http/Middleware/RequestTest.php b/tests/Http/Middleware/RequestTest.php index ea5559665..61aa0c271 100644 --- a/tests/Http/Middleware/RequestTest.php +++ b/tests/Http/Middleware/RequestTest.php @@ -41,7 +41,7 @@ public function testNoPrefixOrDomainDoesNotMatch() $request = Request::create('foo', 'GET'); $this->middleware->handle($request, function ($handled) use ($request) { - $this->assertEquals($handled, $request); + $this->assertSame($handled, $request); }); } @@ -74,7 +74,7 @@ public function testPrefixMatchesAndSendsRequestThroughRouter() $request = Request::create('bing/bar/foo', 'GET'); $this->middleware->handle($request, function ($handled) use ($request) { - $this->assertEquals($handled, $request); + $this->assertSame($handled, $request); }); } @@ -95,7 +95,7 @@ public function testDomainMatchesAndSendsRequestThroughRouter() $request = Request::create('http://bing.foo.bar/baz', 'GET'); $this->middleware->handle($request, function ($handled) use ($request) { - $this->assertEquals($handled, $request); + $this->assertSame($handled, $request); }); } } diff --git a/tests/Http/Parser/AcceptTest.php b/tests/Http/Parser/AcceptTest.php index 78d6f279e..49d21be46 100644 --- a/tests/Http/Parser/AcceptTest.php +++ b/tests/Http/Parser/AcceptTest.php @@ -14,9 +14,9 @@ public function testParsingInvalidAcceptReturnsDefaults() $accept = $parser->parse($this->createRequest('foo', 'GET', ['accept' => 'application/vnd.foo.v2+xml'])); - $this->assertEquals('api', $accept['subtype']); - $this->assertEquals('v1', $accept['version']); - $this->assertEquals('json', $accept['format']); + $this->assertSame('api', $accept['subtype']); + $this->assertSame('v1', $accept['version']); + $this->assertSame('json', $accept['format']); } /** @@ -36,9 +36,9 @@ public function testParsingValidAcceptReturnsHeaderValues() $accept = $parser->parse($this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v2+xml'])); - $this->assertEquals('api', $accept['subtype']); - $this->assertEquals('v2', $accept['version']); - $this->assertEquals('xml', $accept['format']); + $this->assertSame('api', $accept['subtype']); + $this->assertSame('v2', $accept['version']); + $this->assertSame('xml', $accept['format']); } public function testApiVersionWithoutVSuffix() @@ -47,9 +47,9 @@ public function testApiVersionWithoutVSuffix() $accept = $parser->parse($this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.1.0+xml'])); - $this->assertEquals('api', $accept['subtype']); - $this->assertEquals('1.0', $accept['version']); - $this->assertEquals('xml', $accept['format']); + $this->assertSame('api', $accept['subtype']); + $this->assertSame('1.0', $accept['version']); + $this->assertSame('xml', $accept['format']); } protected function createRequest($uri, $method, array $headers = []) diff --git a/tests/Http/RateLimit/HandlerTest.php b/tests/Http/RateLimit/HandlerTest.php index 0e0df589e..b09738d36 100644 --- a/tests/Http/RateLimit/HandlerTest.php +++ b/tests/Http/RateLimit/HandlerTest.php @@ -64,6 +64,6 @@ public function testGettingTheRemainingLimit() { $this->limiter->extend(new ThrottleStub(['limit' => 10, 'expires' => 200])); $this->limiter->rateLimitRequest(Request::create('test', 'GET')); - $this->assertEquals(9, $this->limiter->getRemainingLimit()); + $this->assertSame(9, $this->limiter->getRemainingLimit()); } } diff --git a/tests/Http/Response/FactoryTest.php b/tests/Http/Response/FactoryTest.php index 96e44db02..984587c75 100644 --- a/tests/Http/Response/FactoryTest.php +++ b/tests/Http/Response/FactoryTest.php @@ -27,12 +27,12 @@ public function testMakingACreatedResponse() $response = $this->factory->created(); $responseWithLocation = $this->factory->created('test'); - $this->assertEquals($response->getStatusCode(), 201); + $this->assertSame($response->getStatusCode(), 201); $this->assertFalse($response->headers->has('Location')); - $this->assertEquals($responseWithLocation->getStatusCode(), 201); + $this->assertSame($responseWithLocation->getStatusCode(), 201); $this->assertTrue($responseWithLocation->headers->has('Location')); - $this->assertEquals($responseWithLocation->headers->get('Location'), 'test'); + $this->assertSame($responseWithLocation->headers->get('Location'), 'test'); } public function testMakingAnAcceptedResponse() @@ -42,30 +42,30 @@ public function testMakingAnAcceptedResponse() $responseWithContent = $this->factory->accepted(null, 'testContent'); $responseWithBoth = $this->factory->accepted('testHeader', 'testContent'); - $this->assertEquals($response->getStatusCode(), 202); + $this->assertSame($response->getStatusCode(), 202); $this->assertFalse($response->headers->has('Location')); - $this->assertEquals('', $response->getContent()); + $this->assertSame('', $response->getContent()); - $this->assertEquals($responseWithLocation->getStatusCode(), 202); + $this->assertSame($responseWithLocation->getStatusCode(), 202); $this->assertTrue($responseWithLocation->headers->has('Location')); - $this->assertEquals($responseWithLocation->headers->get('Location'), 'testHeader'); - $this->assertEquals('', $responseWithLocation->getContent()); + $this->assertSame($responseWithLocation->headers->get('Location'), 'testHeader'); + $this->assertSame('', $responseWithLocation->getContent()); - $this->assertEquals($responseWithContent->getStatusCode(), 202); + $this->assertSame($responseWithContent->getStatusCode(), 202); $this->assertFalse($responseWithContent->headers->has('Location')); - $this->assertEquals('testContent', $responseWithContent->getContent()); + $this->assertSame('testContent', $responseWithContent->getContent()); - $this->assertEquals($responseWithBoth->getStatusCode(), 202); + $this->assertSame($responseWithBoth->getStatusCode(), 202); $this->assertTrue($responseWithBoth->headers->has('Location')); - $this->assertEquals($responseWithBoth->headers->get('Location'), 'testHeader'); - $this->assertEquals('testContent', $responseWithBoth->getContent()); + $this->assertSame($responseWithBoth->headers->get('Location'), 'testHeader'); + $this->assertSame('testContent', $responseWithBoth->getContent()); } public function testMakingANoContentResponse() { $response = $this->factory->noContent(); - $this->assertEquals(204, $response->getStatusCode()); - $this->assertEquals('', $response->getContent()); + $this->assertSame(204, $response->getStatusCode()); + $this->assertSame('', $response->getContent()); } public function testMakingCollectionRegistersUnderlyingClassWithTransformer() @@ -143,12 +143,12 @@ public function testMethodNotAllowedThrowsHttpException() public function testMakingArrayResponse() { $response = $this->factory->array(['foo' => 'bar']); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); + $this->assertSame('{"foo":"bar"}', $response->getContent()); } public function testPrefixingWithCallsMethodsCorrectly() { $response = $this->factory->withArray(['foo' => 'bar']); - $this->assertEquals('{"foo":"bar"}', $response->getContent()); + $this->assertSame('{"foo":"bar"}', $response->getContent()); } } diff --git a/tests/Http/Response/Format/JsonTest.php b/tests/Http/Response/Format/JsonTest.php index 864e637e5..47b221cfb 100644 --- a/tests/Http/Response/Format/JsonTest.php +++ b/tests/Http/Response/Format/JsonTest.php @@ -30,28 +30,28 @@ public function testMorphingEloquentModel() { $response = (new Response(new EloquentModelStub))->morph(); - $this->assertEquals('{"foo_bar":{"foo":"bar"}}', $response->getContent()); + $this->assertSame('{"foo_bar":{"foo":"bar"}}', $response->getContent()); } public function testMorphingEloquentCollection() { $response = (new Response(new Collection([new EloquentModelStub, new EloquentModelStub])))->morph(); - $this->assertEquals('{"foo_bars":[{"foo":"bar"},{"foo":"bar"}]}', $response->getContent()); + $this->assertSame('{"foo_bars":[{"foo":"bar"},{"foo":"bar"}]}', $response->getContent()); } public function testMorphingEmptyEloquentCollection() { $response = (new Response(new Collection))->morph(); - $this->assertEquals('[]', $response->getContent()); + $this->assertSame('[]', $response->getContent()); } public function testMorphingString() { $response = (new Response('foo'))->morph(); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); } public function testMorphingArray() @@ -60,12 +60,12 @@ public function testMorphingArray() $response = (new Response(['foo' => 'bar', 'baz' => $messages]))->morph(); - $this->assertEquals('{"foo":"bar","baz":{"foo":["bar"]}}', $response->getContent()); + $this->assertSame('{"foo":"bar","baz":{"foo":["bar"]}}', $response->getContent()); } public function testMorphingUnknownType() { - $this->assertEquals(1, (new Response(1))->morph()->getContent()); + $this->assertSame(1, (new Response(1))->morph()->getContent()); } public function testMorphingEloquentModelWithCamelCasing() @@ -74,7 +74,7 @@ public function testMorphingEloquentModelWithCamelCasing() $response = (new Response(new EloquentModelStub))->morph(); - $this->assertEquals('{"fooBar":{"foo":"bar"}}', $response->getContent()); + $this->assertSame('{"fooBar":{"foo":"bar"}}', $response->getContent()); } public function testMorphingEloquentCollectionWithCamelCasing() @@ -83,6 +83,6 @@ public function testMorphingEloquentCollectionWithCamelCasing() $response = (new Response(new Collection([new EloquentModelStub, new EloquentModelStub])))->morph(); - $this->assertEquals('{"fooBars":[{"foo":"bar"},{"foo":"bar"}]}', $response->getContent()); + $this->assertSame('{"fooBars":[{"foo":"bar"},{"foo":"bar"}]}', $response->getContent()); } } diff --git a/tests/Http/Response/Format/JsonpTest.php b/tests/Http/Response/Format/JsonpTest.php index 64563812a..b6aa6ddf5 100644 --- a/tests/Http/Response/Format/JsonpTest.php +++ b/tests/Http/Response/Format/JsonpTest.php @@ -32,28 +32,28 @@ public function testMorphingEloquentModel() { $response = (new Response(new EloquentModelStub))->morph(); - $this->assertEquals('foo({"foo_bar":{"foo":"bar"}});', $response->getContent()); + $this->assertSame('foo({"foo_bar":{"foo":"bar"}});', $response->getContent()); } public function testMorphingEloquentCollection() { $response = (new Response(new Collection([new EloquentModelStub, new EloquentModelStub])))->morph(); - $this->assertEquals('foo({"foo_bars":[{"foo":"bar"},{"foo":"bar"}]});', $response->getContent()); + $this->assertSame('foo({"foo_bars":[{"foo":"bar"},{"foo":"bar"}]});', $response->getContent()); } public function testMorphingEmptyEloquentCollection() { $response = (new Response(new Collection))->morph(); - $this->assertEquals('foo([]);', $response->getContent()); + $this->assertSame('foo([]);', $response->getContent()); } public function testMorphingString() { $response = (new Response('foo'))->morph(); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); } public function testMorphingArray() @@ -62,11 +62,11 @@ public function testMorphingArray() $response = (new Response(['foo' => 'bar', 'baz' => $messages]))->morph(); - $this->assertEquals('foo({"foo":"bar","baz":{"foo":["bar"]}});', $response->getContent()); + $this->assertSame('foo({"foo":"bar","baz":{"foo":["bar"]}});', $response->getContent()); } public function testMorphingUnknownType() { - $this->assertEquals(1, (new Response(1))->morph()->getContent()); + $this->assertSame(1, (new Response(1))->morph()->getContent()); } } diff --git a/tests/Http/ResponseTest.php b/tests/Http/ResponseTest.php index 480079509..726ae6aa7 100644 --- a/tests/Http/ResponseTest.php +++ b/tests/Http/ResponseTest.php @@ -50,7 +50,7 @@ public function testAddingAndSettingMetaCallsUnderlyingTransformerBinding() $response->setMeta(['foo' => 'bar']); $response->meta('bing', 'bang'); - $this->assertEquals(['foo' => 'bar', 'bing' => 'bang'], $response->getMeta()); + $this->assertSame(['foo' => 'bar', 'bing' => 'bang'], $response->getMeta()); } public function testBuildingWithCustomStatusCodeAndHeaders() @@ -59,8 +59,8 @@ public function testBuildingWithCustomStatusCodeAndHeaders() $response->statusCode(302); $response->header('Foo', 'Bar'); - $this->assertEquals('Bar', $response->headers->get('Foo')); - $this->assertEquals(302, $response->getStatusCode()); + $this->assertSame('Bar', $response->headers->get('Foo')); + $this->assertSame(302, $response->getStatusCode()); } public function testChangingContentWithEvents() @@ -73,7 +73,7 @@ public function testChangingContentWithEvents() $response = new Response(['foo' => 'bar']); - $this->assertEquals('{"foo":"bam!"}', $response->morph('json')->getContent()); + $this->assertSame('{"foo":"bam!"}', $response->morph('json')->getContent()); $this->events->forget('Dingo\Api\Event\ResponseWasMorphed'); } @@ -88,7 +88,7 @@ public function testChangingResponseHeadersWithEvents() $response = new Response(['foo' => 'bar']); - $this->assertEquals('bar', $response->morph('json')->headers->get('x-foo')); + $this->assertSame('bar', $response->morph('json')->headers->get('x-foo')); $this->events->forget('Dingo\Api\Event\ResponseIsMorphing'); } diff --git a/tests/Routing/Adapter/BaseAdapterTest.php b/tests/Routing/Adapter/BaseAdapterTest.php index f2a878033..2e14fe4c9 100644 --- a/tests/Routing/Adapter/BaseAdapterTest.php +++ b/tests/Routing/Adapter/BaseAdapterTest.php @@ -84,31 +84,31 @@ public function testBasicRouteVersions() $this->assertArrayHasKey('v3', $this->router->getRoutes(), 'No routes were registered for version 3.'); $request = $this->createRequest('/foo', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent()); + $this->assertSame('foo', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo/', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Could not dispatch request with trailing slash.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Could not dispatch request with trailing slash.'); $request = $this->createRequest('/foo', 'GET', ['accept' => 'application/vnd.api.v2+json']); - $this->assertEquals('bar', $this->router->dispatch($request)->getContent()); + $this->assertSame('bar', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'GET', ['accept' => 'application/vnd.api.v3+json']); - $this->assertEquals('bar', $this->router->dispatch($request)->getContent()); + $this->assertSame('bar', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'POST', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('posted', $this->router->dispatch($request)->getContent()); + $this->assertSame('posted', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'PATCH', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('patched', $this->router->dispatch($request)->getContent()); + $this->assertSame('patched', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'DELETE', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('deleted', $this->router->dispatch($request)->getContent()); + $this->assertSame('deleted', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'PUT', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('put', $this->router->dispatch($request)->getContent()); + $this->assertSame('put', $this->router->dispatch($request)->getContent()); $request = $this->createRequest('/foo', 'options', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('options', $this->router->dispatch($request)->getContent()); + $this->assertSame('options', $this->router->dispatch($request)->getContent()); } public function testAdapterDispatchesRequestsThroughRouter() @@ -123,7 +123,7 @@ public function testAdapterDispatchesRequestsThroughRouter() $response = $this->router->dispatch($this->container['request']); - $this->assertEquals('foo', $response->getContent()); + $this->assertSame('foo', $response->getContent()); } public function testRoutesWithPrefix() @@ -141,7 +141,7 @@ public function testRoutesWithPrefix() }); $request = $this->createRequest('/foo/bar/foo', 'GET', ['accept' => 'application/vnd.api.v2+json']); - $this->assertEquals('bar', $this->router->dispatch($request)->getContent(), 'Router could not dispatch prefixed routes.'); + $this->assertSame('bar', $this->router->dispatch($request)->getContent(), 'Router could not dispatch prefixed routes.'); } public function testRoutesWithDomains() @@ -159,7 +159,7 @@ public function testRoutesWithDomains() }); $request = $this->createRequest('http://foo.bar/foo', 'GET', ['accept' => 'application/vnd.api.v2+json']); - $this->assertEquals('bar', $this->router->dispatch($request)->getContent(), 'Router could not dispatch domain routes.'); + $this->assertSame('bar', $this->router->dispatch($request)->getContent(), 'Router could not dispatch domain routes.'); } public function testPointReleaseVersions() @@ -177,10 +177,10 @@ public function testPointReleaseVersions() }); $request = $this->createRequest('/foo', 'GET', ['accept' => 'application/vnd.api.v1.1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router does not support point release versions.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Router does not support point release versions.'); $request = $this->createRequest('/bar', 'GET', ['accept' => 'application/vnd.api.v2.0.1+json']); - $this->assertEquals('bar', $this->router->dispatch($request)->getContent(), 'Router does not support point release versions.'); + $this->assertSame('bar', $this->router->dispatch($request)->getContent(), 'Router does not support point release versions.'); } public function testRoutingControllers() @@ -193,7 +193,7 @@ public function testRoutingControllers() $request = $this->createRequest('/bar/index', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); $this->router->version('v2', function () { $this->router->controllers([ @@ -203,7 +203,7 @@ public function testRoutingControllers() $request = $this->createRequest('/bar/index', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); } public function testRoutingResources() @@ -216,7 +216,7 @@ public function testRoutingResources() $request = $this->createRequest('/bar', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Router did not register controller correctly.'); } public function testIterableRoutes() @@ -228,6 +228,6 @@ public function testIterableRoutes() $routes = $this->adapter->getIterableRoutes(); $this->assertTrue(array_key_exists('v1', (array) $routes)); - $this->assertEquals(2, count($routes['v1'])); + $this->assertSame(2, count($routes['v1'])); } } diff --git a/tests/Routing/RouteTest.php b/tests/Routing/RouteTest.php index bc6086ec9..0a16a5e32 100644 --- a/tests/Routing/RouteTest.php +++ b/tests/Routing/RouteTest.php @@ -40,10 +40,10 @@ public function testCreatingNewRoute() ], ]); - $this->assertEquals(['foo', 'bar'], $route->scopes(), 'Route did not setup scopes correctly.'); - $this->assertEquals(['foo'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); - $this->assertEquals(5, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); - $this->assertEquals(10, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); + $this->assertSame(['foo', 'bar'], $route->scopes(), 'Route did not setup scopes correctly.'); + $this->assertSame(['foo'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); + $this->assertSame(5, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); + $this->assertSame(10, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); $this->assertTrue($route->hasThrottle(), 'Route did not setup throttle correctly.'); $this->assertInstanceOf('Dingo\Api\Tests\Stubs\BasicThrottleStub', $route->getThrottle(), 'Route did not setup throttle correctly.'); $this->assertFalse($route->requestIsConditional(), 'Route did not setup conditional request correctly.'); @@ -68,10 +68,10 @@ public function testControllerOptionsMergeAndOverrideRouteOptions() ], ]); - $this->assertEquals(['foo', 'bar', 'baz', 'bing'], $route->scopes(), 'Route did not setup scopes correctly.'); - $this->assertEquals(['foo', 'red', 'black'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); - $this->assertEquals(10, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); - $this->assertEquals(20, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); + $this->assertSame(['foo', 'bar', 'baz', 'bing'], $route->scopes(), 'Route did not setup scopes correctly.'); + $this->assertSame(['foo', 'red', 'black'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); + $this->assertSame(10, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); + $this->assertSame(20, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); $this->assertTrue($route->hasThrottle(), 'Route did not setup throttle correctly.'); $this->assertInstanceOf('Dingo\Api\Tests\Stubs\BasicThrottleStub', $route->getThrottle(), 'Route did not setup throttle correctly.'); @@ -90,10 +90,10 @@ public function testControllerOptionsMergeAndOverrideRouteOptions() ], ]); - $this->assertEquals(['foo', 'bar', 'baz', 'bing', 'bob'], $route->scopes(), 'Route did not setup scopes correctly.'); - $this->assertEquals(['foo'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); - $this->assertEquals(10, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); - $this->assertEquals(20, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); + $this->assertSame(['foo', 'bar', 'baz', 'bing', 'bob'], $route->scopes(), 'Route did not setup scopes correctly.'); + $this->assertSame(['foo'], $route->getAuthenticationProviders(), 'Route did not setup authentication providers correctly.'); + $this->assertSame(10, $route->getRateLimit(), 'Route did not setup rate limit correctly.'); + $this->assertSame(20, $route->getRateLimitExpiration(), 'Route did not setup rate limit expiration correctly.'); $this->assertTrue($route->hasThrottle(), 'Route did not setup throttle correctly.'); $this->assertInstanceOf('Dingo\Api\Tests\Stubs\BasicThrottleStub', $route->getThrottle(), 'Route did not setup throttle correctly.'); } diff --git a/tests/Routing/RouterTest.php b/tests/Routing/RouterTest.php index a6c00c843..f02adda05 100644 --- a/tests/Routing/RouterTest.php +++ b/tests/Routing/RouterTest.php @@ -25,7 +25,7 @@ public function testRouteOptionsMergeCorrectly() { $this->router->version('v1', ['scopes' => 'foo|bar'], function () { $this->router->get('foo', ['scopes' => ['baz'], function () { - $this->assertEquals( + $this->assertSame( ['foo', 'bar', 'baz'], $this->router->getCurrentRoute()->getScopes(), 'Router did not merge string based group scopes with route based array scopes.' @@ -33,7 +33,7 @@ public function testRouteOptionsMergeCorrectly() }]); $this->router->get('baz', function () { - $this->assertEquals( + $this->assertSame( ['foo', 'bar'], $this->router->getCurrentRoute()->getScopes(), 'Router did not merge string based group scopes with route.' @@ -56,10 +56,10 @@ public function testRouteOptionsMergeCorrectly() $route = $this->router->getCurrentRoute(); - $this->assertEquals(['baz', 'bing'], $route->scopes()); - $this->assertEquals(['foo', 'red', 'black'], $route->getAuthenticationProviders()); - $this->assertEquals(10, $route->getRateLimit()); - $this->assertEquals(20, $route->getRateLimitExpiration()); + $this->assertSame(['baz', 'bing'], $route->scopes()); + $this->assertSame(['foo', 'red', 'black'], $route->getAuthenticationProviders()); + $this->assertSame(10, $route->getRateLimit()); + $this->assertSame(20, $route->getRateLimitExpiration()); $this->assertInstanceOf('Dingo\Api\Tests\Stubs\BasicThrottleStub', $route->getThrottle()); } @@ -101,15 +101,15 @@ public function testMatchRoutes() $request = $this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); $response = $this->router->dispatch( $request = $this->createRequest('foo', 'POST', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); } public function testAnyRoutes() @@ -126,29 +126,29 @@ public function testAnyRoutes() $request = $this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); $response = $this->router->dispatch( $request = $this->createRequest('foo', 'POST', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); $response = $this->router->dispatch( $request = $this->createRequest('foo', 'PATCH', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); $response = $this->router->dispatch( $request = $this->createRequest('foo', 'DELETE', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); } public function testRouterPreparesNotModifiedResponse() @@ -165,16 +165,16 @@ public function testRouterPreparesNotModifiedResponse() $request = $this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('bar', $response->getContent()); $this->router->setConditionalRequest(true); $response = $this->router->dispatch($request); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('"'.md5('bar').'"', $response->getETag()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('"'.md5('bar').'"', $response->getETag()); + $this->assertSame('bar', $response->getContent()); $request = $this->createRequest('foo', 'GET', [ 'if-none-match' => '"'.md5('bar').'"', @@ -183,9 +183,9 @@ public function testRouterPreparesNotModifiedResponse() $response = $this->router->dispatch($request); - $this->assertEquals(304, $response->getStatusCode()); - $this->assertEquals('"'.md5('bar').'"', $response->getETag()); - $this->assertEquals(null, $response->getContent()); + $this->assertSame(304, $response->getStatusCode()); + $this->assertSame('"'.md5('bar').'"', $response->getETag()); + $this->assertEmpty($response->getContent()); $request = $this->createRequest('foo', 'GET', [ 'if-none-match' => '123456789', @@ -194,9 +194,9 @@ public function testRouterPreparesNotModifiedResponse() $response = $this->router->dispatch($request); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('"'.md5('bar').'"', $response->getETag()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('"'.md5('bar').'"', $response->getETag()); + $this->assertSame('bar', $response->getContent()); } public function testRouterHandlesExistingEtag() @@ -214,9 +214,9 @@ public function testRouterHandlesExistingEtag() $this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v1+json']) ); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('"custom-etag"', $response->getETag()); - $this->assertEquals('bar', $response->getContent()); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('"custom-etag"', $response->getETag()); + $this->assertSame('bar', $response->getContent()); } public function testRouterHandlesCustomEtag() @@ -237,9 +237,9 @@ public function testRouterHandlesCustomEtag() ]) ); - $this->assertEquals(304, $response->getStatusCode()); - $this->assertEquals('"custom-etag"', $response->getETag()); - $this->assertEquals(null, $response->getContent()); + $this->assertSame(304, $response->getStatusCode()); + $this->assertSame('"custom-etag"', $response->getETag()); + $this->assertEmpty($response->getContent()); } public function testExceptionsAreHandledByExceptionHandler() @@ -257,7 +257,7 @@ public function testExceptionsAreHandledByExceptionHandler() $request = $this->createRequest('foo', 'GET', ['accept' => 'application/vnd.api.v1+json']); - $this->assertEquals('exception', $this->router->dispatch($request)->getContent(), 'Router did not delegate exception handling.'); + $this->assertSame('exception', $this->router->dispatch($request)->getContent(), 'Router did not delegate exception handling.'); } public function testNoAcceptHeaderUsesDefaultVersion() @@ -268,7 +268,7 @@ public function testNoAcceptHeaderUsesDefaultVersion() }); }); - $this->assertEquals('foo', $this->router->dispatch($this->createRequest('foo', 'GET'))->getContent(), 'Router does not default to default version.'); + $this->assertSame('foo', $this->router->dispatch($this->createRequest('foo', 'GET'))->getContent(), 'Router does not default to default version.'); } public function testRoutesAddedToCorrectVersions() @@ -302,7 +302,7 @@ public function testUnsuccessfulResponseThrowsHttpException() $this->exception->shouldReceive('handle')->with(m::type('Symfony\Component\HttpKernel\Exception\HttpException'))->andReturn(new Http\Response('Failed!')); - $this->assertEquals('Failed!', $this->router->dispatch($request)->getContent(), 'Router did not throw and handle a HttpException.'); + $this->assertSame('Failed!', $this->router->dispatch($request)->getContent(), 'Router did not throw and handle a HttpException.'); } public function testGroupNamespacesAreConcatenated() @@ -315,7 +315,7 @@ public function testGroupNamespacesAreConcatenated() $request = $this->createRequest('foo', 'GET'); - $this->assertEquals('foo', $this->router->dispatch($request)->getContent(), 'Router did not concatenate controller namespace correctly.'); + $this->assertSame('foo', $this->router->dispatch($request)->getContent(), 'Router did not concatenate controller namespace correctly.'); } public function testCurrentRouteName() diff --git a/tests/Transformer/FactoryTest.php b/tests/Transformer/FactoryTest.php index cc2283b03..6ec48e631 100644 --- a/tests/Transformer/FactoryTest.php +++ b/tests/Transformer/FactoryTest.php @@ -39,20 +39,20 @@ public function testRegisterParameterOrder() { // Third parameter is parameters and fourth is callback. $binding = $this->factory->register('Dingo\Api\Tests\Stubs\UserStub', new UserTransformerStub, ['foo' => 'bar'], function ($foo) { - $this->assertEquals('foo', $foo); + $this->assertSame('foo', $foo); }); $binding->fireCallback('foo'); - $this->assertEquals(['foo' => 'bar'], $binding->getParameters()); + $this->assertSame(['foo' => 'bar'], $binding->getParameters()); // Third parameter is parameters and fourth is null. $binding = $this->factory->register('Dingo\Api\Tests\Stubs\UserStub', new UserTransformerStub, ['foo' => 'bar']); - $this->assertEquals(['foo' => 'bar'], $binding->getParameters()); + $this->assertSame(['foo' => 'bar'], $binding->getParameters()); // Third parameter is callback and fourth is null. $binding = $this->factory->register('Dingo\Api\Tests\Stubs\UserStub', new UserTransformerStub, function ($foo) { - $this->assertEquals('foo', $foo); + $this->assertSame('foo', $foo); }); $binding->fireCallback('foo'); @@ -71,7 +71,7 @@ public function testTransformingResponse() $response = $this->factory->transform(new UserStub('Jason')); - $this->assertEquals(['name' => 'Jason'], $response); + $this->assertSame(['name' => 'Jason'], $response); } public function testTransformingCollectionResponse() @@ -80,7 +80,7 @@ public function testTransformingCollectionResponse() $response = $this->factory->transform(new Collection([new UserStub('Jason'), new UserStub('Bob')])); - $this->assertEquals([['name' => 'Jason'], ['name' => 'Bob']], $response); + $this->assertSame([['name' => 'Jason'], ['name' => 'Bob']], $response); } public function testTransforingWithIlluminateRequest() @@ -94,7 +94,7 @@ public function testTransforingWithIlluminateRequest() $response = $factory->transform(new UserStub('Jason')); - $this->assertEquals(['name' => 'Jason'], $response); + $this->assertSame(['name' => 'Jason'], $response); } /**