Skip to content

Commit

Permalink
Adding a service alias method
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Jun 20, 2014
1 parent c132fa5 commit 3679dfa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/OAuth.php
Expand Up @@ -86,4 +86,17 @@ public function consumer($service, $url = null, $scope = null)
return $this->factory->createService($service, $credentials, $this->storage, $scope);
}

/**
* Consumer alias method.
*
* @param string $service
* @param string $url
* @param array $scope
* @return \OAuth\Common\Service\AbstractService
*/
public function service($service, $url = null, $scope = null)
{
return $this->consumer($service, $url, $scope);
}

}
13 changes: 13 additions & 0 deletions tests/OAuthTest.php
Expand Up @@ -59,6 +59,19 @@ public function testCreatesConsumer()
$this->assertInstanceOf('OAuth\OAuth2\Service\Facebook', $consumer);
}

public function testServiceAlias()
{
Config::set('oauth::consumers.facebook.client_id', '123');
Config::set('oauth::consumers.facebook.client_secret', 'ABC');

$serviceFactory = Mockery::mock('OAuth\ServiceFactory');
$serviceFactory->shouldReceive('createService')->passthru();

$oauth = new OAuth($serviceFactory, new Memory);
$consumer = $oauth->service('facebook');
$this->assertInstanceOf('OAuth\OAuth2\Service\Facebook', $consumer);
}

public function testReturnsConsumer()
{
Config::set('oauth::consumers.facebook.client_id', '123');
Expand Down

0 comments on commit 3679dfa

Please sign in to comment.