Skip to content

Commit

Permalink
upgrade to better naming with bovigo/callmap 3.2.0
Browse files Browse the repository at this point in the history
 - bovigo/callmap updated from v3.1.1 to v3.2.0
   See changes: bovigo/callmap@v3.1.1...v3.2.0
   Release notes: https://github.com/mikey179/bovigo-callmap/releases/tag/v3.2.0
  • Loading branch information
mikey179 committed Aug 6, 2016
1 parent 13c4449 commit 22faa23
Show file tree
Hide file tree
Showing 27 changed files with 156 additions and 156 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"stubbles/image": "^5.0",
"phpunit/phpunit": "^5.4",
"mikey179/vfsStream": "^1.6",
"bovigo/callmap": "^3.1",
"bovigo/callmap": "^3.2",
"bovigo/assert": "^2.0"
},
"autoload": {
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions src/test/php/WebAppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ public function tearDown()
private function createResource(): UriResource
{
$resource = NewInstance::of(UriResource::class);
$this->routing->mapCalls(['findResource' => $resource]);
$this->routing->returns(['findResource' => $resource]);
return $resource;
}

private function createNonHttpsResource(array $callmap = []): UriResource
{
$resource = $this->createResource();
$resource->mapCalls(array_merge(
$resource->returns(array_merge(
['requiresHttps' => false,
'negotiateMimeType' => true,
'applyPreInterceptors' => true,
Expand All @@ -114,7 +114,7 @@ private function createNonHttpsResource(array $callmap = []): UriResource
public function respondsWithRedirectHttpsUriIfRequiresHttps()
{
$resource = $this->createResource();
$resource->mapCalls([
$resource->returns([
'requiresHttps' => true,
'httpsUri' => HttpUri::fromString('https://example.net/admin')
]);
Expand All @@ -134,8 +134,8 @@ public function respondsWithRedirectHttpsUriIfRequiresHttps()
public function doesNotExecuteInterceptorsAndResourceIfMimeTypeNegotiationFails ()
{
$resource = NewInstance::of(UriResource::class);
$this->routing->mapCalls(['findResource' => $resource]);
$resource->mapCalls([
$this->routing->returns(['findResource' => $resource]);
$resource->returns([
'requiresHttps' => false,
'negotiateMimeType' => false
]);
Expand Down Expand Up @@ -201,7 +201,7 @@ public function doesNotExecuteRouteAndPostInterceptorsIfPreInterceptorCancelsReq
private function setUpExceptionLogger(): ExceptionLogger
{
$exceptionLogger = NewInstance::stub(ExceptionLogger::class);
$this->injector->mapCalls(['getInstance' => $exceptionLogger]);
$this->injector->returns(['getInstance' => $exceptionLogger]);
return $exceptionLogger;

}
Expand Down
44 changes: 22 additions & 22 deletions src/test/php/auth/ProtectedResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function setUp()
*/
public function requiresSwitchToHttpsWhenActualRouteDoes()
{
$this->actualResource->mapCalls(['requiresHttps' => true]);
$this->actualResource->returns(['requiresHttps' => true]);
assertTrue($this->protectedResource->requiresHttps());
}

Expand All @@ -103,7 +103,7 @@ public function requiresSwitchToHttpsWhenActualRouteDoes()
public function returnsHttpsUriOfActualRoute()
{
$httpsUri = HttpUri::fromString('https://example.com/hello');
$this->actualResource->mapCalls(['httpsUri' => $httpsUri]);
$this->actualResource->returns(['httpsUri' => $httpsUri]);
assert($this->protectedResource->httpsUri(), isSameAs($httpsUri));
}

Expand All @@ -113,7 +113,7 @@ public function returnsHttpsUriOfActualRoute()
*/
public function delegatesMimeTypeNegotiationToActualRoute()
{
$this->actualResource->mapCalls(['negotiateMimeType' => true]);
$this->actualResource->returns(['negotiateMimeType' => true]);
assertTrue(
$this->protectedResource->negotiateMimeType(
$this->request,
Expand All @@ -127,7 +127,7 @@ public function delegatesMimeTypeNegotiationToActualRoute()
*/
public function returnsSupportedMimeTypesOfActualRoute()
{
$this->actualResource->mapCalls(['supportedMimeTypes' => ['application/foo']]);
$this->actualResource->returns(['supportedMimeTypes' => ['application/foo']]);
assert(
$this->protectedResource->supportedMimeTypes(),
equals(['application/foo'])
Expand All @@ -137,8 +137,8 @@ public function returnsSupportedMimeTypesOfActualRoute()
private function createAuthenticationProvider(array $callmap = []): AuthenticationProvider
{
$authenticationProvider = NewInstance::of(AuthenticationProvider::class);
$this->injector->mapCalls(['getInstance' => $authenticationProvider]);
return $authenticationProvider->mapCalls($callmap);
$this->injector->returns(['getInstance' => $authenticationProvider]);
return $authenticationProvider->returns($callmap);
}

/**
Expand All @@ -149,7 +149,7 @@ public function applyPreInterceptorsTriggersInternalServerErrorWhenAuthenticatio
{
$e = new InternalAuthProviderException('error');
$this->createAuthenticationProvider(['authenticate' => throws($e)]);
$this->response->mapCalls(['internalServerError' => Error::internalServerError($e)]);
$this->response->returns(['internalServerError' => Error::internalServerError($e)]);
assertTrue(
$this->protectedResource->applyPreInterceptors(
$this->request,
Expand Down Expand Up @@ -221,7 +221,7 @@ public function applyPreInterceptorsTriggers403ForbiddenWhenNotAuthenticatedAndR
{
$this->authConstraint->forbiddenWhenNotAlreadyLoggedIn();
$this->createAuthenticationProvider();
$this->response->mapCalls(['forbidden' => Error::forbidden()]);
$this->response->returns(['forbidden' => Error::forbidden()]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand All @@ -247,7 +247,7 @@ public function applyPreInterceptorsCallsActualRouteWhenAuthenticatedAndNoSpecif
'authenticate' => NewInstance::of(User::class)
]);

$this->actualResource->mapCalls(['applyPreInterceptors' => true]);
$this->actualResource->returns(['applyPreInterceptors' => true]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand All @@ -264,18 +264,18 @@ public function storesUserInRequestIdentityWhenAuthenticated()
$this->authConstraint->requireLogin();
$this->createAuthenticationProvider(['authenticate' => $user]);
$request = WebRequest::fromRawSource();
$this->actualResource->mapCalls(['applyPreInterceptors' => true]);
$this->actualResource->returns(['applyPreInterceptors' => true]);
$this->protectedResource->applyPreInterceptors($request, $this->response);
assert($request->identity()->user(), isSameAs($user));
}

private function createAuthorizationProvider($roles, User $user = null): AuthorizationProvider
{
$authenticationProvider = NewInstance::of(AuthenticationProvider::class)
->mapCalls(['authenticate' => ($user === null) ? NewInstance::of(User::class) : $user]);
->returns(['authenticate' => ($user === null) ? NewInstance::of(User::class) : $user]);
$authorizationProvider = NewInstance::of(AuthorizationProvider::class)
->mapCalls(['roles' => $roles]);
$this->injector->mapCalls([
->returns(['roles' => $roles]);
$this->injector->returns([
'getInstance' => onConsecutiveCalls(
$authenticationProvider,
$authorizationProvider
Expand All @@ -293,7 +293,7 @@ public function applyPreInterceptorsTriggersInternalServerErrorWhenAuthorization
$e = new InternalAuthProviderException('error');
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(throws($e));
$this->response->mapCalls(['internalServerError' => Error::internalServerError($e)]);
$this->response->returns(['internalServerError' => Error::internalServerError($e)]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand Down Expand Up @@ -343,7 +343,7 @@ public function applyPreInterceptorsTriggers403ForbiddenWhenNotAuthorized()
{
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(Roles::none());
$this->response->mapCalls(['forbidden' => Error::forbidden()]);
$this->response->returns(['forbidden' => Error::forbidden()]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand All @@ -366,7 +366,7 @@ public function applyPreInterceptorsCallsActualRouteWhenAuthenticatedAndAuthoriz
{
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(new Roles(['admin']));
$this->actualResource->mapCalls(['applyPreInterceptors' => true]);
$this->actualResource->returns(['applyPreInterceptors' => true]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand All @@ -383,7 +383,7 @@ public function storesUserInRequestIdentityWhenAuthenticatedAndAuthorized()
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(new Roles(['admin']), $user);
$request = WebRequest::fromRawSource();
$this->actualResource->mapCalls(['applyPreInterceptors' => true]);
$this->actualResource->returns(['applyPreInterceptors' => true]);
$this->protectedResource->applyPreInterceptors(
$request,
$this->response
Expand All @@ -400,7 +400,7 @@ public function storesRolesInRequestIdentityWhenAuthenticatedAndAuthorized()
$roles = new Roles(['admin']);
$this->createAuthorizationProvider($roles);
$request = WebRequest::fromRawSource();
$this->actualResource->mapCalls(['applyPreInterceptors' => true]);
$this->actualResource->returns(['applyPreInterceptors' => true]);
$this->protectedResource->applyPreInterceptors(
$request,
$this->response
Expand All @@ -427,7 +427,7 @@ public function resolveCallsResolveOfActualRouteWhenAuthorized()
{
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(new Roles(['admin']));
$this->actualResource->mapCalls([
$this->actualResource->returns([
'applyPreInterceptors' => true, 'resolve' => 'foo'
]);
assertTrue($this->protectedResource->applyPreInterceptors(
Expand All @@ -450,8 +450,8 @@ public function appliesPostInterceptorsWhenNotAuthorized()
{
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(Roles::none());
$this->actualResource->mapCalls(['applyPostInterceptors' => true]);
$this->response->mapCalls(['forbidden' => Error::forbidden()]);
$this->actualResource->returns(['applyPostInterceptors' => true]);
$this->response->returns(['forbidden' => Error::forbidden()]);
assertTrue($this->protectedResource->applyPreInterceptors(
$this->request,
$this->response
Expand All @@ -471,7 +471,7 @@ public function appliesPostInterceptorsWhenAuthorized()
{
$this->authConstraint->requireRole('admin');
$this->createAuthorizationProvider(new Roles(['admin']));
$this->actualResource->mapCalls([
$this->actualResource->returns([
'applyPreInterceptors' => true,
'resolve' => 'foo',
'applyPostInterceptors' => true
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/auth/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function canCreateTokenFromUser()
{
assert(
Token::create(
NewInstance::of(User::class)->mapCalls([
NewInstance::of(User::class)->returns([
'name' => 'Heinz Mustermann',
'firstName' => 'Heinz',
'lastName' => 'Mustermann',
Expand Down
10 changes: 5 additions & 5 deletions src/test/php/auth/session/CachingAuthenticationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function annotationsPresentOnConstructor()
public function usesSessionValueIfUserStoredInSession()
{
$user = NewInstance::of(User::class);
$this->session->mapCalls(['hasValue' => true, 'value' => $user]);
$this->session->returns(['hasValue' => true, 'value' => $user]);
assert(
$this->cachingAuthenticationProvider->authenticate(
NewInstance::of(Request::class)
Expand All @@ -102,7 +102,7 @@ public function usesSessionValueIfUserStoredInSession()
*/
public function doesNotStoreReturnValueWhenOriginalAuthenticationProviderReturnsNull()
{
$this->session->mapCalls(['hasValue' => false]);
$this->session->returns(['hasValue' => false]);
assertNull(
$this->cachingAuthenticationProvider->authenticate(
NewInstance::of(Request::class)
Expand All @@ -117,8 +117,8 @@ public function doesNotStoreReturnValueWhenOriginalAuthenticationProviderReturns
public function storeReturnValueInSessionWhenOriginalAuthenticationProviderReturnsUser()
{
$user = NewInstance::of(User::class);
$this->session->mapCalls(['hasValue' => false]);
$this->authenticationProvider->mapCalls(['authenticate' => $user]);
$this->session->returns(['hasValue' => false]);
$this->authenticationProvider->returns(['authenticate' => $user]);
assert(
$this->cachingAuthenticationProvider->authenticate(
NewInstance::of(Request::class)
Expand All @@ -133,7 +133,7 @@ public function storeReturnValueInSessionWhenOriginalAuthenticationProviderRetur
*/
public function returnsLoginUriFromOriginalAuthenticationProvider()
{
$this->authenticationProvider->mapCalls([
$this->authenticationProvider->returns([
'loginUri' => 'http://login.example.net/'
]);
assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function annotationsPresentOnConstructor()
public function usesSessionValueIfRolesStoredInSession()
{
$roles = new Roles(['admin']);
$this->session->mapCalls(['hasValue' => true, 'value' => $roles]);
$this->session->returns(['hasValue' => true, 'value' => $roles]);
assert(
$this->cachingAuthorizationProvider->roles(
NewInstance::of(User::class)
Expand All @@ -102,8 +102,8 @@ public function usesSessionValueIfRolesStoredInSession()
public function storeReturnValueInSessionWhenOriginalAuthenticationProviderReturnsRoles()
{
$roles = new Roles(['admin']);
$this->session->mapCalls(['hasValue' => false]);
$this->authorizationProvider->mapCalls(['roles' => $roles]);
$this->session->returns(['hasValue' => false]);
$this->authorizationProvider->returns(['roles' => $roles]);
assert(
$this->cachingAuthorizationProvider->roles(
NewInstance::of(User::class)
Expand Down
Loading

0 comments on commit 22faa23

Please sign in to comment.