diff --git a/.travis.yml b/.travis.yml index f80b7928f..dd4aae4a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ cache: directories: - $HOME/.composer/cache - vendor - - $HOME/cphalcon php: - 5.3 - 5.4 @@ -21,16 +20,11 @@ services: - mongodb - redis-server - cassandra -- mysql -- memcached before_install: - - composer install --prefer-source --no-interaction - - vendor/bin/install-phalcon.sh - - phpenv config-rm xdebug.ini || return 0 +- phpenv config-rm xdebug.ini || return 0 install: - composer install --no-interaction before_script: -- php -m - psql -c 'create database oauth2_server_php;' -U postgres after_script: - php test/cleanup.php diff --git a/composer.json b/composer.json index 5b8f3ced2..b1f28c707 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,6 @@ "aws/aws-sdk-php": "~2.8", "firebase/php-jwt": "~2.2", "predis/predis": "dev-master", - "thobbs/phpcassa": "dev-master", - "techpivot/phalcon-ci-installer": "~1.0" + "thobbs/phpcassa": "dev-master" } } diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php b/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php index 03162a24e..f4c162a91 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php @@ -61,7 +61,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth_access_tokens'"); + $this->setSource("'oauth__access_tokens'"); $this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User")); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client")); } @@ -73,7 +73,7 @@ public function initialize() */ public function getSource() { - return 'oauth_access_tokens'; + return 'oauth__access_tokens'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php b/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php index da4c1903e..1d7e5001e 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php @@ -54,7 +54,7 @@ class OauthAuthorizationCodes extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth_authorization_codes'; + return 'oauth__authorization_codes'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthClients.php b/src/OAuth2/Storage/Phalcon/Models/OauthClients.php index 3e81b1dc6..a7a7c7b57 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthClients.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthClients.php @@ -68,7 +68,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth_clients'"); + $this->setSource("'oauth__clients'"); $this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User")); } @@ -79,7 +79,7 @@ public function initialize() */ public function getSource() { - return 'oauth_clients'; + return 'oauth__clients'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthJti.php b/src/OAuth2/Storage/Phalcon/Models/OauthJti.php index 9c3378710..cbd5a1c90 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthJti.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthJti.php @@ -42,7 +42,7 @@ class OauthJti extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth_jti'; + return 'oauth__jti'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php b/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php index 9c85795af..bebd42691 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php @@ -50,7 +50,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth_jwt'"); + $this->setSource("'oauth__jwt'"); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client")); } @@ -61,7 +61,7 @@ public function initialize() */ public function getSource() { - return 'oauth_jwt'; + return 'oauth__jwt'; } public function getClient($parameters = null) diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php b/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php index 95e4361c7..f954dd3da 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php @@ -56,7 +56,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth_public_keys'"); + $this->setSource("'oauth__public_keys'"); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client")); } @@ -67,7 +67,7 @@ public function initialize() */ public function getSource() { - return 'oauth_public_keys'; + return 'oauth__public_keys'; } public function getClient($parameters = null) diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php b/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php index ef201b5b5..c3046f6e8 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php @@ -61,7 +61,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth_refresh_tokens'"); + $this->setSource("'oauth__refresh_tokens'"); $this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username'); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id'); } @@ -73,7 +73,7 @@ public function initialize() */ public function getSource() { - return 'oauth_refresh_tokens'; + return 'oauth__refresh_tokens'; } } \ No newline at end of file diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php b/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php index 721766596..32187decb 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php @@ -24,7 +24,7 @@ class OauthScopes extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth_scopes'; + return 'oauth__scopes'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php b/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php index aed45d13b..f3846ad86 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php @@ -77,7 +77,7 @@ public static function findFirst($parameters = null) public function initialize() { $this->keepSnapshots(true); - $this->setSource("'oauth_users'"); + $this->setSource("'oauth__users'"); $this->hasMany('username', 'OAuth2\Storage\Phalcon\Models\OauthAccessTokens', 'user_id', array("alias" => "AccessTokens")); $this->hasMany('username', 'OAuth2\Storage\Phalcon\Models\OauthRefreshTokens', 'user_id', array("alias" => "RefreshTokens")); } @@ -112,7 +112,7 @@ public function validation() */ public function getSource() { - return 'oauth_users'; + return 'oauth__users'; } /** diff --git a/src/OAuth2/Storage/Phalcon/Phalcon.php b/src/OAuth2/Storage/Phalcon/Phalcon.php index 6436293ba..0b449be10 100644 --- a/src/OAuth2/Storage/Phalcon/Phalcon.php +++ b/src/OAuth2/Storage/Phalcon/Phalcon.php @@ -43,9 +43,6 @@ class Phalcon implements */ public function __construct($di, $config = array()) { - if(!isset($di['db'])) - throw new \InvalidArgumentException('Dependency injector must contain a valid database connection'); - $this->di = $di; $this->config = array_merge(array( 'client_table' => 'oauth_clients', diff --git a/test/OAuth2/AutoloadTest.php b/test/OAuth2/AutoloadTest.php index baba16b8d..5901bdc42 100644 --- a/test/OAuth2/AutoloadTest.php +++ b/test/OAuth2/AutoloadTest.php @@ -12,7 +12,5 @@ public function testClassesExist() $this->assertTrue(class_exists('OAuth2\Response')); $this->assertTrue(class_exists('OAuth2\GrantType\UserCredentials')); $this->assertTrue(interface_exists('OAuth2\Storage\AccessTokenInterface')); - $this->assertTrue(class_exists('OAuth2\Storage\Phalcon\Phalcon')); - $this->assertTrue(class_exists('OAuth2\Storage\Phalcon\Models\OauthUsers')); } } diff --git a/test/OAuth2/Storage/Phalcon/PhalconTest.php b/test/OAuth2/Storage/Phalcon/PhalconTest.php deleted file mode 100644 index a12237652..000000000 --- a/test/OAuth2/Storage/Phalcon/PhalconTest.php +++ /dev/null @@ -1,101 +0,0 @@ -checkExtension('phalcon'); - // Reset the DI container - Di::reset(); - // Instantiate a new DI container - $di = new Di(); - // Set the URL - $di->set( - 'url', - function () { - $url = new Url(); - $url->setBaseUri('/'); - return $url; - } - ); - - $di->set( - 'escaper', - function () { - return new Escaper(); - } - ); - - $di->set('db', function() { - return new Mysql(array( - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "oauth2_server_php", - )); - }); - - $di->set( - 'modelsManager', - function () { - return new Manager(); - } - ); - - $di->set( - 'modelsMetadata', - function () { - return new Memory(); - } - ); - - $this->di = $di; - } - - public function checkExtension($extension) - { - $message = function ($ext) { - sprintf('Warning: %s extension is not loaded', $ext); - }; - if (is_array($extension)) { - foreach ($extension as $ext) { - if (!extension_loaded($ext)) { - $this->markTestSkipped($message($ext)); - break; - } - } - } elseif (!extension_loaded($extension)) { - $this->markTestSkipped($message($extension)); - } - } - - public function testPhalconDataStorage(){ - $this->setUp(); - $storage = new Phalcon($this->di); - $this->assertNotNull($storage->getClientDetails('oauth_test_client')); - } - -} \ No newline at end of file diff --git a/test/OAuth2/Storage/PhalconTest.php b/test/OAuth2/Storage/PhalconTest.php new file mode 100644 index 000000000..5ee4c29ae --- /dev/null +++ b/test/OAuth2/Storage/PhalconTest.php @@ -0,0 +1,15 @@ +