8000 Pulling master by cclep · Pull Request #1 · cclep/api · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Pulling master #1

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 2 commits into from
Aug 18, 2016
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
6 changes: 3 additions & 3 deletions tests/Auth/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testAuthenticationIsSuccessfulAndUserIsSet()

$user = $this->auth->authenticate();

$this->assertEquals(1, $user->id);
$this->assertSame(1, $user->id);
}

public function testProvidersAreFilteredWhenSpecificProviderIsRequested()
Expand All @@ -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()
Expand All @@ -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());
}
}
2 changes: 1 addition & 1 deletion tests/Auth/Provider/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
}
}
4 changes: 2 additions & 2 deletions tests/Auth/Provider/JWTTest.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
}
}
4 changes: 2 additions & 2 deletions tests/Auth/Provider/OAuth2Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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));
}
}
76 changes: 39 additions & 37 deletions tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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'));
}

/**
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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());
});
});

Expand All @@ -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()
Expand All @@ -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'));
});
});

Expand All @@ -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());
}]);
});

Expand All @@ -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'));
});
});

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -363,7 +365,7 @@ public function testUsingRequestFacadeDoesNotCacheRequestInstance()
10000
$response = $this->dispatcher->with(['foo' => 'bar'])->get('foo');

$this->assertEquals('bar', $response);
$this->assertSame('bar', $response);
$this->assertNull(RequestFacade::input('foo'));
}
}
32 changes: 16 additions & 16 deletions tests/Exception/HandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -164,6 +164,6 @@ public function testSettingUserDefinedReplacements()

$response = $this->exceptionHandler->handle($exception);

$this->assertEquals('{"bing":"bar"}', $response->getContent());
$this->assertSame('{"bing":"bar"}', $response->getContent());
}
}
4 changes: 2 additions & 2 deletions tests/Http/Middleware/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

Expand All @@ -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);
});
}

Expand Down
Loading
0