Skip to content

Commit

Permalink
Phalcon travis ci config (#2)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lucasantarella authored Jul 5, 2016
1 parent cfd5166 commit fa994c1
Show file tree
Hide file tree
Showing 15 changed files with 378 additions and 49 deletions.
10 changes: 7 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 4 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthAccessTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAccessTokens extends \Phalcon\Mvc\Model
{
/**
Expand Down Expand Up @@ -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"));
}
Expand All @@ -73,7 +75,7 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__access_tokens';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getAccessTokenTable();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthAuthorizationCodes extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -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();
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthClients.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthClients extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -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"));
}

Expand All @@ -79,7 +81,7 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__clients';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getClientTable();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/OAuth2/Storage/Phalcon/Models/OauthJti.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthJti extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -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();
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthJwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthJwt extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -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"));
}

Expand All @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/OAuth2/Storage/Phalcon/Models/OauthPublicKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthPublicKeys extends \Phalcon\Mvc\Model
{

Expand Down Expand Up @@ -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"));
}

Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthRefreshTokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthRefreshTokens extends \Phalcon\Mvc\Model
{
/**
Expand Down Expand Up @@ -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');
}
Expand All @@ -73,7 +75,6 @@ public function initialize()
*/
public function getSource()
{
return 'oauth__refresh_tokens';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getRefreshTokenTable();
}

}
4 changes: 3 additions & 1 deletion src/OAuth2/Storage/Phalcon/Models/OauthScopes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2\Storage\Phalcon\Models;

use OAuth2\Storage\Phalcon\Phalcon;

class OauthScopes extends \Phalcon\Mvc\Model
{

Expand All @@ -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();
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/OAuth2/Storage/Phalcon/Models/OauthUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"));
}
Expand Down Expand Up @@ -112,7 +113,7 @@ public function validation()
*/
public function getSource()
{
return 'oauth__users';
return $this->getDI()->get(Phalcon::KEY_PHALCON_CONFIG_ARRAY)->getUserTable();
}

/**
Expand All @@ -132,5 +133,5 @@ public function getRefreshTokens($parameters = null)
{
return $this->getRelated('RefreshTokens', $parameters);
}

}
Loading

0 comments on commit fa994c1

Please sign in to comment.