diff --git a/.travis.yml b/.travis.yml index 90f471b..025ccd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,10 @@ php: - 7.2 - 7.3 +cache: + directories: + - ~/cphalcon + matrix: fast_finish: true @@ -23,6 +27,7 @@ before_script: - composer self-update - composer install --no-interaction --no-progress + - if [[ $TRAVIS_PHP_VERSION == "5.5" ]] || [[ $TRAVIS_PHP_VERSION == "5.6" ]] || [[ $TRAVIS_PHP_VERSION == "7.0" ]] || [[ $TRAVIS_PHP_VERSION == "7.1" ]] || [[ $TRAVIS_PHP_VERSION == "7.2" ]]; then vendor/bin/install-phalcon.sh 3.4.x && echo "Phalcon version " && php --ri phalcon && php -r 'var_dump(class_exists(\Phalcon\Di\FactoryDefault\Cli::class));'; fi script: - ./tests/run-unit.sh diff --git a/composer.json b/composer.json index 8005053..20954f4 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "symfony/console": "~2.6 | ~3.0 | ~4.0", "symfony/dependency-injection": "~2.6 | ~3.0 | ~4.0", "symfony/http-kernel": "~2.6 | ~3.0 | ~4.0", + "techpivot/phalcon-ci-installer": "~1.0", "tracy/tracy": "^2.2", "ext-openssl": "*" }, diff --git a/tests/cases/integration/phalcon/PhalconTest.phpt b/tests/cases/integration/phalcon/PhalconTest.phpt new file mode 100644 index 0000000..aa0b79d --- /dev/null +++ b/tests/cases/integration/phalcon/PhalconTest.phpt @@ -0,0 +1,140 @@ +set( + 'config', + new \Phalcon\Config([ + 'migrationsDir' => __DIR__ . "/../../../fixtures/$options[driver]", + 'host' => $dbalOptions['host'], + 'username' => $dbalOptions['database'], + 'password' => $dbalOptions['username'], + 'dbname' => $dbalOptions['password'], + ]) + ); + $di->set( + 'migrationsDir', + function () { + /** @var \Phalcon\Config $config */ + $config = $this->get('config'); + return $config->migrationsDir; + } + ); + $di->set( + 'phalconAdapter', + function () { + /** @var \Phalcon\Db\Adapter\Pdo $connection */ + $connection = $this->get('connection'); + return new \Nextras\Migrations\Bridges\Phalcon\PhalconAdapter($connection); + } + ); + + if ($options['driver'] === 'mysql') { + $di->set( + 'connection', + function () { + /** @var \Phalcon\Config $config */ + $config = $this->get('config'); + return new \Phalcon\Db\Adapter\Pdo\Mysql([ + 'host' => $config->database->host, + 'username' => $config->database->username, + 'password' => $config->database->password, + 'dbname' => $config->database->dbname, + 'dialectClass' => new \Phalcon\Db\Dialect\Mysql(), + ]); + } + ); + $di->set( + 'driver', + function () { + /** @var \Nextras\Migrations\Bridges\Phalcon\PhalconAdapter $phalconAdapter */ + $phalconAdapter = $this->get('phalconAdapter'); + return new \Nextras\Migrations\Drivers\MySqlDriver($phalconAdapter); + } + ); + } else { + $di->set( + 'connection', + function () { + /** @var \Phalcon\Config $config */ + $config = $this->get('config'); + return new \Phalcon\Db\Adapter\Pdo\Postgresql([ + 'host' => $config->database->host, + 'username' => $config->database->username, + 'password' => $config->database->password, + 'dbname' => $config->database->dbname, + 'dialectClass' => new \Phalcon\Db\Dialect\Mysql(), + ]); + } + ); + $di->set( + 'driver', + function () { + /** @var \Nextras\Migrations\Bridges\Phalcon\PhalconAdapter $phalconAdapter */ + $phalconAdapter = $this->get('phalconAdapter'); + return new \Nextras\Migrations\Drivers\PgSqlDriver($phalconAdapter); + } + ); + } + + // Create a console application + $this->console = new \Phalcon\Cli\Console(); + $this->console->setDI($di); + } + + + public function testMigrationsReset() + { + $arguments['task'] = 'main'; + $arguments['action'] = 'reset'; + $arguments['params'] = ['reset']; + + Assert::null($this->console->handle($arguments)); + } + + + public function testMigrationsContinue() + { + $arguments['task'] = 'main'; + $arguments['action'] = 'main'; + $arguments['params'] = ['continue']; + + Assert::null($this->console->handle($arguments)); + } +} + + +(new PhalconTest)->run(); diff --git a/tests/matrix/dbal/phalcon-3.4.sh b/tests/matrix/dbal/phalcon-3.4.sh new file mode 100644 index 0000000..1d8c839 --- /dev/null +++ b/tests/matrix/dbal/phalcon-3.4.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +PHP_VERSION_MIN="50500" +PHP_VERSION_MAX="70299" +COMPOSER_REQUIRE="$COMPOSER_REQUIRE doctrine/dbal:~2.5" +DBAL="doctrine" diff --git a/tests/matrix/phalcon/phalcon-php-5.5-to-7.2.sh b/tests/matrix/phalcon/phalcon-php-5.5-to-7.2.sh new file mode 100644 index 0000000..aab849c --- /dev/null +++ b/tests/matrix/phalcon/phalcon-php-5.5-to-7.2.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +PHP_VERSION_MIN="50500" +PHP_VERSION_MAX="70299" +DBAL='doctrine' +PHALCON=true diff --git a/tests/run-integration.sh b/tests/run-integration.sh index 5fb5476..0320e55 100755 --- a/tests/run-integration.sh +++ b/tests/run-integration.sh @@ -15,6 +15,7 @@ run() PHP_VERSION_MAX="" COMPOSER_REQUIRE="" DBAL="" + PHALCON="" echo echo @@ -33,7 +34,7 @@ run() return 0 fi - create_dbals_ini "$DBAL" + create_dbals_ini "$DBAL" "$PHALCON" composer_prepare_dependencies "$COMPOSER_REQUIRE" "" tester_run_integration_group "$INTEGRATION_GROUP" @@ -51,9 +52,11 @@ run() create_dbals_ini() { DBAL="$1" + PHALCON="$2" INI_PATH="$PROJECT_DIR/tests/dbals.ini" rm --force "$INI_PATH" + if [[ ! -z "$DBAL" ]]; then echo "[$DBAL.mysql]" >> "$INI_PATH" echo "dbal = $DBAL" >> "$INI_PATH" @@ -63,6 +66,10 @@ create_dbals_ini() echo "dbal = $DBAL" >> "$INI_PATH" echo "driver = pgsql" >> "$INI_PATH" fi + + if [[ ! -z "$PHALCON" ]]; then + echo "extension=phalcon.so" >> "$INI_PATH" + fi }