From fa994c1d64a48597860ccb95c69b3d6aee992fd5 Mon Sep 17 00:00:00 2001 From: Luca Santarella Date: Tue, 5 Jul 2016 12:23:45 -0400 Subject: [PATCH] Phalcon travis ci config (#2) * Added Travis CI installer for Phalcon * Travis CI config for phalcon * Refactored to the corresponding directory for the Phalcon classes * Added phalcon autoload tests * Test test * Get client details test * Init DB for phalcon test * Refactored di connection * More tests * Disabled throwing an exception * Setup methods * Fixed table names * Finalize tests * Min php version set to 5.3.21 * Removed manually setting the phalcon version * Php 5.3.29 for Phalcon Zephir * Added dev packages * using sudo * Installing 2.0.x of phalcon * Removed PHP7 and HHVM from config * Using dynamic table names for the library * Using getShared instead of getRaw * Fixed recursion depth * Using get instead of getShared * Using function * Using special config class * Added special phalcon conf class * Using containerbased infrastructure * Fixed not sending the class in the di * Moved the conf class back to the Phalcon main class --- .travis.yml | 10 +- composer.json | 3 +- .../Phalcon/Models/OauthAccessTokens.php | 6 +- .../Models/OauthAuthorizationCodes.php | 4 +- .../Storage/Phalcon/Models/OauthClients.php | 6 +- .../Storage/Phalcon/Models/OauthJti.php | 4 +- .../Storage/Phalcon/Models/OauthJwt.php | 8 +- .../Phalcon/Models/OauthPublicKeys.php | 7 +- .../Phalcon/Models/OauthRefreshTokens.php | 7 +- .../Storage/Phalcon/Models/OauthScopes.php | 4 +- .../Storage/Phalcon/Models/OauthUsers.php | 7 +- src/OAuth2/Storage/Phalcon/Phalcon.php | 245 +++++++++++++++++- test/OAuth2/AutoloadTest.php | 2 + test/OAuth2/Storage/Phalcon/PhalconTest.php | 99 +++++++ test/OAuth2/Storage/PhalconTest.php | 15 -- 15 files changed, 378 insertions(+), 49 deletions(-) create mode 100644 test/OAuth2/Storage/Phalcon/PhalconTest.php delete mode 100644 test/OAuth2/Storage/PhalconTest.php diff --git a/.travis.yml b/.travis.yml index dd4aae4a6..1d463fe44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,12 @@ cache: directories: - $HOME/.composer/cache - vendor + - $HOME/cphalcon php: - 5.3 - 5.4 - 5.5 - 5.6 -- 7 -- hhvm env: global: - SKIP_MONGO_TESTS=1 @@ -20,11 +19,16 @@ services: - mongodb - redis-server - cassandra +- mysql +- memcached before_install: -- phpenv config-rm xdebug.ini || return 0 + - composer install --prefer-source --no-interaction + - vendor/bin/install-phalcon.sh 2.0.x + - 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 b1f28c707..5b8f3ced2 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "aws/aws-sdk-php": "~2.8", "firebase/php-jwt": "~2.2", "predis/predis": "dev-master", - "thobbs/phpcassa": "dev-master" + "thobbs/phpcassa": "dev-master", + "techpivot/phalcon-ci-installer": "~1.0" } } diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php b/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php index f4c162a91..bb5c79f4a 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthAccessTokens extends \Phalcon\Mvc\Model { /** @@ -61,7 +63,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth__access_tokens'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getAccessTokenTable() . "'"); $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 +75,7 @@ public function initialize() */ public function getSource() { - return 'oauth__access_tokens'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getAccessTokenTable(); } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php b/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php index 1d7e5001e..e2e3fef89 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthAuthorizationCodes.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthAuthorizationCodes extends \Phalcon\Mvc\Model { @@ -54,7 +56,7 @@ class OauthAuthorizationCodes extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth__authorization_codes'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getCodeTable(); } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthClients.php b/src/OAuth2/Storage/Phalcon/Models/OauthClients.php index a7a7c7b57..86a8f6645 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthClients.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthClients.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthClients extends \Phalcon\Mvc\Model { @@ -68,7 +70,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth__clients'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getClientTable() . "'"); $this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username', array("alias" => "User")); } @@ -79,7 +81,7 @@ public function initialize() */ public function getSource() { - return 'oauth__clients'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getClientTable(); } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthJti.php b/src/OAuth2/Storage/Phalcon/Models/OauthJti.php index cbd5a1c90..5461c39d6 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthJti.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthJti.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthJti extends \Phalcon\Mvc\Model { @@ -42,7 +44,7 @@ class OauthJti extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth__jti'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJtiTable(); } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php b/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php index bebd42691..5faed3d2b 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthJwt.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthJwt extends \Phalcon\Mvc\Model { @@ -50,7 +52,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth__jwt'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJwtTable() . "'"); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client")); } @@ -61,9 +63,9 @@ public function initialize() */ public function getSource() { - return 'oauth__jwt'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getJwtTable(); } - + public function getClient($parameters = null) { return $this->getRelated('Client', $parameters); diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php b/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php index f954dd3da..bb2a14326 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthPublicKeys extends \Phalcon\Mvc\Model { @@ -56,7 +58,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth__public_keys'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getPublicKeyTable() . "'"); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id', array("alias" => "Client")); } @@ -67,9 +69,10 @@ public function initialize() */ public function getSource() { - return 'oauth__public_keys'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getPublicKeyTable(); } + public function getClient($parameters = null) { return $this->getRelated('Client', $parameters); diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php b/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php index c3046f6e8..8d77e5da8 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthRefreshTokens extends \Phalcon\Mvc\Model { /** @@ -61,7 +63,7 @@ public static function findFirst($parameters = null) */ public function initialize() { - $this->setSource("'oauth__refresh_tokens'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getRefreshTokenTable() . "'"); $this->belongsTo('user_id', 'OAuth2\Storage\Phalcon\Models\OauthUsers', 'username'); $this->belongsTo('client_id', 'OAuth2\Storage\Phalcon\Models\OauthClients', 'client_id'); } @@ -73,7 +75,6 @@ public function initialize() */ public function getSource() { - return 'oauth__refresh_tokens'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getRefreshTokenTable(); } - } \ 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 32187decb..a66f93e35 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthScopes.php @@ -2,6 +2,8 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; + class OauthScopes extends \Phalcon\Mvc\Model { @@ -24,7 +26,7 @@ class OauthScopes extends \Phalcon\Mvc\Model */ public function getSource() { - return 'oauth__scopes'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getScopeTable(); } /** diff --git a/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php b/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php index f3846ad86..cdf9b12fb 100644 --- a/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php +++ b/src/OAuth2/Storage/Phalcon/Models/OauthUsers.php @@ -2,6 +2,7 @@ namespace OAuth2\Storage\Phalcon\Models; +use OAuth2\Storage\Phalcon\Phalcon; use Phalcon\Mvc\Model\Validator\Email as Email; class OauthUsers extends \Phalcon\Mvc\Model @@ -77,7 +78,7 @@ public static function findFirst($parameters = null) public function initialize() { $this->keepSnapshots(true); - $this->setSource("'oauth__users'"); + $this->setSource("'" . $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getUserTable() . "'"); $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 +113,7 @@ public function validation() */ public function getSource() { - return 'oauth__users'; + return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getUserTable(); } /** @@ -132,5 +133,5 @@ public function getRefreshTokens($parameters = null) { return $this->getRelated('RefreshTokens', $parameters); } - + } \ No newline at end of file diff --git a/src/OAuth2/Storage/Phalcon/Phalcon.php b/src/OAuth2/Storage/Phalcon/Phalcon.php index 0b449be10..105ef4185 100644 --- a/src/OAuth2/Storage/Phalcon/Phalcon.php +++ b/src/OAuth2/Storage/Phalcon/Phalcon.php @@ -33,7 +33,9 @@ class Phalcon implements UserClaimsInterface, OpenIDAuthorizationCodeInterface { + const KEY_PHALCON_CONFIG_ARRAY = 'oauth2_storage_phalcon_config'; protected $db; + protected $di; protected $config; /** @@ -43,8 +45,10 @@ class Phalcon implements */ public function __construct($di, $config = array()) { - $this->di = $di; - $this->config = array_merge(array( + if (!isset($di['db'])) + throw new \InvalidArgumentException('Dependency injector must contain a valid database connection'); + + $phalconConf = new PhalconConf(array_merge(array( 'client_table' => 'oauth_clients', 'access_token_table' => 'oauth_access_tokens', 'refresh_token_table' => 'oauth_refresh_tokens', @@ -54,7 +58,24 @@ public function __construct($di, $config = array()) 'jti_table' => 'oauth_jti', 'scope_table' => 'oauth_scopes', 'public_key_table' => 'oauth_public_keys', - ), $config); + ), $config)); + + $di->set(self::KEY_PHALCON_CONFIG_ARRAY, $phalconConf); + + $manager = $di->get('modelsManager'); + $manager->setDi($di); + $di->set('modelsManager', $manager); + + $this->config = $phalconConf; + $this->di = $di; + } + + /** + * @return \Phalcon\DiInterface + */ + public function getDi() + { + return $this->di; } /* OAuth2\Storage\ClientCredentialsInterface */ @@ -575,7 +596,7 @@ public function getEncryptionAlgorithm($client_id = null) public function getBuildSql($dbName = 'oauth2_server_php') { $sql = " - CREATE TABLE {$this->config['client_table']} ( + CREATE TABLE {$this->config->getClientTable()} ( `client_id` varchar(80) NOT NULL, `client_secret` varchar(80) DEFAULT NULL, `redirect_uri` varchar(2000) DEFAULT NULL, @@ -585,7 +606,7 @@ public function getBuildSql($dbName = 'oauth2_server_php') PRIMARY KEY (client_id) ); - CREATE TABLE {$this->config['access_token_table']} ( + CREATE TABLE {$this->config->getAccessTokenTable()} ( `access_token` varchar(40) NOT NULL, `valid` tinyint(1) NOT NULL DEFAULT '1', `client_ip` varchar(155) NOT NULL, @@ -597,7 +618,7 @@ public function getBuildSql($dbName = 'oauth2_server_php') PRIMARY KEY (access_token) ); - CREATE TABLE {$this->config['code_table']} ( + CREATE TABLE {$this->config->getCodeTable()} ( `authorization_code` varchar(40) NOT NULL, `client_id` varchar(80) NOT NULL, `user_id` varchar(80) DEFAULT NULL, @@ -608,7 +629,7 @@ public function getBuildSql($dbName = 'oauth2_server_php') PRIMARY KEY (authorization_code) ); - CREATE TABLE {$this->config['refresh_token_table']} ( + CREATE TABLE {$this->config->getRefreshTokenTable()} ( `refresh_token` varchar(40) NOT NULL, `valid` tinyint(1) NOT NULL DEFAULT '1', `client_id` varchar(80) NOT NULL, @@ -620,7 +641,7 @@ public function getBuildSql($dbName = 'oauth2_server_php') PRIMARY KEY (refresh_token) ); - CREATE TABLE {$this->config['user_table']} ( + CREATE TABLE {$this->config->getUserTable()} ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `status` tinyint(2) NOT NULL DEFAULT '0', `username` varchar(80) NOT NULL DEFAULT '', @@ -633,19 +654,19 @@ public function getBuildSql($dbName = 'oauth2_server_php') PRIMARY KEY (id) ); - CREATE TABLE {$this->config['scope_table']} ( + CREATE TABLE {$this->config->getScopeTable()} ( `scope` varchar(80) NOT NULL, `is_default` tinyint(1) DEFAULT NULL, PRIMARY KEY (scope) ); - CREATE TABLE {$this->config['jwt_table']} ( + CREATE TABLE {$this->config->getJwtTable()} ( `client_id` varchar(80) NOT NULL, `subject` varchar(80) DEFAULT NULL, `public_key` varchar(2000) NOT NULL ); - CREATE TABLE {$this->config['jti_table']} ( + CREATE TABLE {$this->config->getJtiTable()} ( `issuer` varchar(80) NOT NULL, `subject` varchar(80) DEFAULT NULL, `audience` varchar(80) DEFAULT NULL, @@ -653,7 +674,7 @@ public function getBuildSql($dbName = 'oauth2_server_php') `jti` varchar(2000) NOT NULL ); - CREATE TABLE {$this->config['public_key_table']} ( + CREATE TABLE {$this->config->getPublicKeyTable()} ( `client_id` varchar(80) DEFAULT NULL, `public_key` varchar(2000) DEFAULT NULL, `private_key` varchar(2000) DEFAULT NULL, @@ -664,4 +685,204 @@ public function getBuildSql($dbName = 'oauth2_server_php') return $sql; } +} + + +/** + * Class PhalconConf + * @package OAuth2\Storage\Phalcon + * + * This config class is used purely internally for communication + * between the model files and the main Phalcon storage class + * for setting table names dynamically. + */ +class PhalconConf +{ + private $client_table; + private $access_token_table; + private $refresh_token_table; + private $code_table; + private $user_table; + private $jwt_table; + private $jti_table; + private $scope_table; + private $public_key_table; + + /** + * PhalconConf constructor. + * @param array $config + * @throws \UnexpectedValueException + */ + public function __construct($config) + { + if ( + isset($config['client_table']) && + isset($config['access_token_table']) && + isset($config['refresh_token_table']) && + isset($config['code_table']) && + isset($config['user_table']) && + isset($config['jwt_table']) && + isset($config['jti_table']) && + isset($config['scope_table']) && + isset($config['public_key_table']) + ) { + $this->setClientTable($config['client_table']); + $this->setAccessTokenTable($config['access_token_table']); + $this->setRefreshTokenTable($config['refresh_token_table']); + $this->setCodeTable($config['code_table']); + $this->setUserTable($config['user_table']); + $this->setJwtTable($config['jwt_table']); + $this->setJtiTable($config['jti_table']); + $this->setScopeTable($config['scope_table']); + $this->setPublicKeyTable($config['public_key_table']); + } else { + throw new \UnexpectedValueException('Config array must contain all keys!'); + } + } + + + /** + * @return mixed + */ + public function getClientTable() + { + return $this->client_table; + } + + /** + * @param mixed $client_table + */ + public function setClientTable($client_table) + { + $this->client_table = $client_table; + } + + /** + * @return mixed + */ + public function getAccessTokenTable() + { + return $this->access_token_table; + } + + /** + * @param mixed $access_token_table + */ + public function setAccessTokenTable($access_token_table) + { + $this->access_token_table = $access_token_table; + } + + /** + * @return mixed + */ + public function getRefreshTokenTable() + { + return $this->refresh_token_table; + } + + /** + * @param mixed $refresh_token_table + */ + public function setRefreshTokenTable($refresh_token_table) + { + $this->refresh_token_table = $refresh_token_table; + } + + /** + * @return mixed + */ + public function getCodeTable() + { + return $this->code_table; + } + + /** + * @param mixed $code_table + */ + public function setCodeTable($code_table) + { + $this->code_table = $code_table; + } + + /** + * @return mixed + */ + public function getUserTable() + { + return $this->user_table; + } + + /** + * @param mixed $user_table + */ + public function setUserTable($user_table) + { + $this->user_table = $user_table; + } + + /** + * @return mixed + */ + public function getJwtTable() + { + return $this->jwt_table; + } + + /** + * @param mixed $jwt_table + */ + public function setJwtTable($jwt_table) + { + $this->jwt_table = $jwt_table; + } + + /** + * @return mixed + */ + public function getJtiTable() + { + return $this->jti_table; + } + + /** + * @param mixed $jti_table + */ + public function setJtiTable($jti_table) + { + $this->jti_table = $jti_table; + } + + /** + * @return mixed + */ + public function getScopeTable() + { + return $this->scope_table; + } + + /** + * @param mixed $scope_table + */ + public function setScopeTable($scope_table) + { + $this->scope_table = $scope_table; + } + + /** + * @return mixed + */ + public function getPublicKeyTable() + { + return $this->public_key_table; + } + + /** + * @param mixed $public_key_table + */ + public function setPublicKeyTable($public_key_table) + { + $this->public_key_table = $public_key_table; + } + } \ No newline at end of file diff --git a/test/OAuth2/AutoloadTest.php b/test/OAuth2/AutoloadTest.php index 5901bdc42..baba16b8d 100644 --- a/test/OAuth2/AutoloadTest.php +++ b/test/OAuth2/AutoloadTest.php @@ -12,5 +12,7 @@ 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 new file mode 100644 index 000000000..479209679 --- /dev/null +++ b/test/OAuth2/Storage/Phalcon/PhalconTest.php @@ -0,0 +1,99 @@ +checkExtension('phalcon'); + // Reset the DI container + Di::reset(); + + // Instantiate a new DI container (this would automatically be created in a normal Phalcon install) + $di = new Di(); + $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 deleted file mode 100644 index 5ee4c29ae..000000000 --- a/test/OAuth2/Storage/PhalconTest.php +++ /dev/null @@ -1,15 +0,0 @@ -