Cleaned up tests

This commit is contained in:
Alex Bilbie 2014-05-03 10:55:25 +01:00
parent ed7f5370ca
commit 5c8ed58c67
22 changed files with 75 additions and 88 deletions

View File

@ -3,11 +3,10 @@
namespace LeagueTests;
use LeagueTests\Stubs\StubAbstractServer;
use \Mockery as M;
class AbstractTokenTest extends \PHPUnit_Framework_TestCase
class AbstractServerTest extends \PHPUnit_Framework_TestCase
{
function testSetGet()
public function testSetGet()
{
$server = new StubAbstractServer();
$this->assertTrue($server->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
@ -17,7 +16,7 @@ class AbstractTokenTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($server2->getRequest() instanceof \Symfony\Component\HttpFoundation\Request);
}
function testGetStorageException()
public function testGetStorageException()
{
$this->setExpectedException('League\OAuth2\Server\Exception\ServerErrorException');
$server = new StubAbstractServer();

View File

@ -7,7 +7,7 @@ use League\OAuth2\Server\Grant\GrantTypeInterface;
use League\OAuth2\Server\Storage\ScopeInterface;
use \Mockery as M;
class AuthorizationTest extends \PHPUnit_Framework_TestCase
class AuthorizationServerTest extends \PHPUnit_Framework_TestCase
{
public function testSetGet()
{

View File

@ -1,6 +1,5 @@
<?php
if ( ! @include_once __DIR__ . '/../vendor/autoload.php')
{
if (! @include_once __DIR__ . '/../vendor/autoload.php') {
exit("You must set up the project dependencies, run the following commands:\n> wget http://getcomposer.org/composer.phar\n> php composer.phar install\n");
}

View File

@ -8,7 +8,7 @@ use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\AuthorizationServer;
use \Mockery as M;
class AbstractTokenTests extends \PHPUnit_Framework_TestCase
class AbstractTokenTest extends \PHPUnit_Framework_TestCase
{
public function testSetGet()
{

View File

@ -5,12 +5,11 @@ namespace LeagueTests\Entity;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\AuthorizationServer;
use \Mockery as M;
class AccessTokenTests extends \PHPUnit_Framework_TestCase
class AccessTokenTest extends \PHPUnit_Framework_TestCase
{
function testSave()
public function testSave()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setAccessTokenStorage');
@ -40,7 +39,7 @@ class AccessTokenTests extends \PHPUnit_Framework_TestCase
$this->assertTrue($entity->save() instanceof AccessTokenEntity);
}
function testExpire()
public function testExpire()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');

View File

@ -10,7 +10,7 @@ use \Mockery as M;
class AuthCodeTest extends \PHPUnit_Framework_TestCase
{
function testSetGet()
public function testSetGet()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
@ -26,7 +26,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($code->getSession() instanceof \League\OAuth2\Server\Entity\SessionEntity);
}
function testSave()
public function testSave()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setAuthCodeStorage');
@ -57,7 +57,7 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($entity->save() instanceof AuthCodeEntity);
}
function testExpire()
public function testExpire()
{
$server = new AuthorizationServer();

View File

@ -6,12 +6,11 @@ use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\AuthorizationServer as Authorization;
use \Mockery as M;
class RefreshTokenTests extends \PHPUnit_Framework_TestCase
class RefreshTokenTest extends \PHPUnit_Framework_TestCase
{
function testSetAccessToken()
public function testSetAccessToken()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$entity = new RefreshTokenEntity($server);
@ -24,7 +23,7 @@ class RefreshTokenTests extends \PHPUnit_Framework_TestCase
$this->assertTrue($accessTokenProperty->getValue($entity) instanceof AccessTokenEntity);
}
function testSave()
public function testSave()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setAccessTokenStorage');
@ -63,7 +62,7 @@ class RefreshTokenTests extends \PHPUnit_Framework_TestCase
$this->assertSame(null, $entity->save());
}
function testExpire()
public function testExpire()
{
$server = M::mock('League\OAuth2\Server\AbstractServer');
$server->shouldReceive('setRefreshTokenStorage');

View File

@ -5,7 +5,7 @@ namespace LeagueTests\Entity;
use League\OAuth2\Server\Entity\ScopeEntity;
use \Mockery as M;
class ScopeTests extends \PHPUnit_Framework_TestCase
class ScopeTest extends \PHPUnit_Framework_TestCase
{
public function testSetGet()
{

View File

@ -3,7 +3,6 @@
namespace LeagueTests\Entity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\AuthCodeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\Entity\SessionEntity;
@ -11,7 +10,7 @@ use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\AuthorizationServer;
use \Mockery as M;
class SessionTests extends \PHPUnit_Framework_TestCase
class SessionTest extends \PHPUnit_Framework_TestCase
{
public function testSetGet()
{
@ -114,7 +113,7 @@ class SessionTests extends \PHPUnit_Framework_TestCase
$this->assertFalse($entity->hasScope('foo'));
}
function testSave()
public function testSave()
{
$server = M::mock('League\OAuth2\Server\AuthorizationServer');
$server->shouldReceive('setSessionStorage');

View File

@ -11,7 +11,7 @@ use Mockery as M;
class AbstractGrantTest extends \PHPUnit_Framework_TestCase
{
function testSetGet()
public function testSetGet()
{
$server = new AuthorizationServer;

View File

@ -121,7 +121,6 @@ class AuthCodeTest extends \PHPUnit_Framework_TestCase
$clientStorage->shouldReceive('setServer');
$clientStorage->shouldReceive('get')->andReturn(null);
$server->setClientStorage($clientStorage);
$server->addGrantType($grant);

View File

@ -6,12 +6,11 @@ use League\OAuth2\Server\Grant\ClientCredentialsGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\Grant\ClientException;
use Mockery as M;
class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
class ClientCredentialsTest extends \PHPUnit_Framework_TestCase
{
function testCompleteFlowMissingClientId()
public function testCompleteFlowMissingClientId()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -25,7 +24,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
}
function testCompleteFlowMissingClientSecret()
public function testCompleteFlowMissingClientSecret()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -41,7 +40,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidClient()
public function testCompleteFlowInvalidClient()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException');
@ -64,7 +63,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidScope()
public function testCompleteFlowInvalidScope()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException');
@ -107,7 +106,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowNoScopes()
public function testCompleteFlowNoScopes()
{
$_POST = [
'grant_type' => 'client_credentials',
@ -151,7 +150,7 @@ class ClientCredentialsGrantTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlow()
public function testCompleteFlow()
{
$_POST = [
'grant_type' => 'client_credentials',

View File

@ -5,15 +5,13 @@ namespace LeagueTests\Grant;
use League\OAuth2\Server\Grant\PasswordGrant;
use League\OAuth2\Server\Grant\RefreshTokenGrant;
use League\OAuth2\Server\Entity\ScopeEntity;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\RefreshTokenEntity;
use League\OAuth2\Server\Entity\ClientEntity;
use League\OAuth2\Server\AuthorizationServer;
use Mockery as M;
class PasswordTest extends \PHPUnit_Framework_TestCase
{
function testCompleteFlowMissingClientId()
public function testCompleteFlowMissingClientId()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -27,7 +25,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
}
function testCompleteFlowMissingClientSecret()
public function testCompleteFlowMissingClientSecret()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -43,7 +41,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidClient()
public function testCompleteFlowInvalidClient()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException');
@ -66,7 +64,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testNoUsername()
public function testNoUsername()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -108,7 +106,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testNoPassword()
public function testNoPassword()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -151,7 +149,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testNoCallable()
public function testNoCallable()
{
$this->setExpectedException('League\OAuth2\Server\Exception\ServerErrorException');
@ -195,7 +193,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidScope()
public function testCompleteFlowInvalidScope()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidScopeException');
@ -243,7 +241,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowNoScopes()
public function testCompleteFlowNoScopes()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -292,7 +290,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidCredentials()
public function testCompleteFlowInvalidCredentials()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidCredentialsException');
@ -348,7 +346,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlow()
public function testCompleteFlow()
{
$_POST = [
'grant_type' => 'password',
@ -407,7 +405,7 @@ class PasswordTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(isset($response['expires']));
}
function testCompleteFlowRefreshToken()
public function testCompleteFlowRefreshToken()
{
$_POST = [
'grant_type' => 'password',

View File

@ -13,7 +13,7 @@ use Mockery as M;
class RefreshTokenTest extends \PHPUnit_Framework_TestCase
{
function testSetRefreshTokenTTL()
public function testSetRefreshTokenTTL()
{
$grant = new RefreshTokenGrant;
$grant->setRefreshTokenTTL(86400);
@ -24,7 +24,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(86400, $property->getValue($grant));
}
function testCompleteFlowMissingClientId()
public function testCompleteFlowMissingClientId()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -37,7 +37,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowMissingClientSecret()
public function testCompleteFlowMissingClientSecret()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -53,7 +53,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidClient()
public function testCompleteFlowInvalidClient()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidClientException');
@ -76,7 +76,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowMissingRefreshToken()
public function testCompleteFlowMissingRefreshToken()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRequestException');
@ -110,7 +110,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowInvalidRefreshToken()
public function testCompleteFlowInvalidRefreshToken()
{
$this->setExpectedException('League\OAuth2\Server\Exception\InvalidRefreshException');
@ -146,7 +146,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$server->issueAccessToken();
}
function testCompleteFlowExistingScopes()
public function testCompleteFlowExistingScopes()
{
$_POST = [
'grant_type' => 'refresh_token',
@ -215,7 +215,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(isset($response['expires']));
}
function testCompleteFlowRequestScopes()
public function testCompleteFlowRequestScopes()
{
$_POST = [
'grant_type' => 'refresh_token',
@ -287,7 +287,7 @@ class RefreshTokenTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(isset($response['expires']));
}
function testCompleteFlowRequestScopesInvalid()
public function testCompleteFlowRequestScopesInvalid()
{
$_POST = [
'grant_type' => 'refresh_token',

View File

@ -3,7 +3,6 @@
namespace LeagueTests;
use League\OAuth2\Server\ResourceServer;
use League\OAuth2\Server\Grant\GrantTypeInterface;
use League\OAuth2\Server\Entity\AccessTokenEntity;
use League\OAuth2\Server\Entity\SessionEntity;
use League\OAuth2\Server\Entity\ClientEntity;
@ -33,7 +32,7 @@ class ResourceServerTest extends \PHPUnit_Framework_TestCase
return $server;
}
function testGetSet()
public function testGetSet()
{
$sessionStorage = M::mock('League\OAuth2\Server\Storage\SessionInterface');
$sessionStorage->shouldReceive('setServer');

View File

@ -4,11 +4,10 @@ namespace LeagueTests\Storage;
use League\OAuth2\Server\Storage\Adapter;
use LeagueTests\Stubs\StubAbstractServer;
use \Mockery as M;
class AdapterTest extends \PHPUnit_Framework_TestCase
{
function testSetGet()
public function testSetGet()
{
$adapter = new Adapter;

View File

@ -1,20 +1,19 @@
<?php
namespace LeagueTests\Util;
namespace LeagueTests\util;
use League\OAuth2\Server\Util\RedirectUri;
use \Mockery as M;
class RedirectUriTest extends \PHPUnit_Framework_TestCase
{
function testMake()
{
$v1 = RedirectUri::make('https://foobar/', array('foo'=>'bar'));
$v2 = RedirectUri::make('https://foobar/', array('foo'=>'bar'), '#');
$v3 = RedirectUri::make('https://foobar/', array('foo'=>'bar', 'bar' => 'foo'));
public function testMake()
{
$v1 = RedirectUri::make('https://foobar/', array('foo'=>'bar'));
$v2 = RedirectUri::make('https://foobar/', array('foo'=>'bar'), '#');
$v3 = RedirectUri::make('https://foobar/', array('foo'=>'bar', 'bar' => 'foo'));
$this->assertEquals('https://foobar/?foo=bar', $v1);
$this->assertEquals('https://foobar/#foo=bar', $v2);
$this->assertEquals('https://foobar/?foo=bar&bar=foo', $v3);
}
$this->assertEquals('https://foobar/?foo=bar', $v1);
$this->assertEquals('https://foobar/#foo=bar', $v2);
$this->assertEquals('https://foobar/?foo=bar&bar=foo', $v3);
}
}

View File

@ -1,13 +1,12 @@
<?php
namespace LeagueTests\Util;
namespace LeagueTests\util;
use \League\OAuth2\Server\Util\SecureKey;
use \Mockery as M;
class SecureKeyTest extends \PHPUnit_Framework_TestCase
{
function testGenerate()
public function testGenerate()
{
$v1 = SecureKey::generate();
$v2 = SecureKey::generate();