Skip to content

Commit

Permalink
Forward method class to the internal factory object
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Jul 5, 2014
1 parent d0378fd commit db33479
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/OAuth.php
Expand Up @@ -99,4 +99,16 @@ public function service($service, $url = null, $scope = null)
return $this->consumer($service, $url, $scope);
}

/**
* Handle dynamic method calls.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
return call_user_func_array(array($this->factory, $method), $parameters);
}

}
2 changes: 1 addition & 1 deletion src/config/config.php
Expand Up @@ -21,7 +21,7 @@
|
| Example:
|
| 'Facebook' => array(
| 'facebook' => array(
| 'client_id' => 'your-client-id',
| 'client_secret' => 'your-client-secret',
| 'scope' => array(),
Expand Down
12 changes: 12 additions & 0 deletions tests/OAuthTest.php
Expand Up @@ -37,6 +37,18 @@ public function testSetsHttpClient()
$oauth = new OAuth($serviceFactory, new Memory);
}

public function testMagicCalls()
{
Config::set('oauth::client', '');

$client = new \OAuth\Common\Http\Client\CurlClient;
$serviceFactory = Mockery::mock('OAuth\ServiceFactory');
$serviceFactory->shouldReceive('setHttpClient')->with($client)->times(1);

$oauth = new OAuth($serviceFactory, new Memory);
$oauth->setHttpClient($client);
}

public function testDefaultHttpClient()
{
Config::set('oauth::client', '');
Expand Down

0 comments on commit db33479

Please sign in to comment.