Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed Nov 28, 2011
1 parent bae7b3c commit 9ecd997
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Tests/Service/OAuth2StorageServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Alb\OAuth2ServiceBundle\Tests\Service;

use Alb\OAuth2ServerBundle\Model\OAuth2Client;
use Alb\OAuth2ServerBundle\Service\OAuth2StorageService;

class OAuth2StorageServiceTest extends \PHPUnit_Framework_TestCase
{
protected $clientManager;
protected $accessTokenManager;
protected $storage;

public function setUp()
{
$this->clientManager = $this->getMock('Alb\OAuth2ServerBundle\Model\OAuth2ClientManagerInterface');
$this->accessTokenManager = $this->getMock('Alb\OAuth2ServerBundle\Model\OAuth2AccessTokenManagerInterface');

$this->storage = new OAuth2StorageService($this->clientManager, $this->accessTokenManager);
}

public function testGetClientReturnsClientWithGivenId()
{
$client = new OAuth2Client;

$this->clientManager->expects($this->once())
->method('findClientByPublicId')
->with('123_abc')
->will($this->returnValue($client));

$this->assertSame($client, $this->storage->getClient('123_abc'));
}
}

14 changes: 14 additions & 0 deletions Tests/autoload.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$vendorDir = __DIR__.'/../../../..';
require_once $vendorDir.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => array($vendorDir.'/symfony/src', $vendorDir.'/bundles'),
'Alb' => $vendorDir.'/bundles',
'OAuth2' => $vendorDir.'/oauth2-php/lib',
));
$loader->register();
8 changes: 8 additions & 0 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}

25 changes: 25 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./Tests/bootstrap.php" color="true">
<!--
<php>
<server name="SYMFONY" value="../../../symfony/src" />
<server name="KERNEL_DIR" value="../../../../app" />
</php>
-->
<testsuites>
<testsuite name="AlbOAuth2ServerBundle">
<directory suffix="Test.php">./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 9ecd997

Please sign in to comment.