Skip to content

Commit

Permalink
Merge pull request phalcon#1095 from phalcon/3.2.x
Browse files Browse the repository at this point in the history
3.2.4
  • Loading branch information
sergeyklay authored Sep 1, 2017
2 parents 6775406 + ac4544f commit 04ccd74
Show file tree
Hide file tree
Showing 30 changed files with 587 additions and 31 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ env:
- TEST_DB_POSTGRESQL_USER="postgres"
- TEST_DB_POSTGRESQL_PASSWD=""
- TEST_DB_POSTGRESQL_NAME="devtools"
- TEST_DB_MYSQL_DSN="mysql:host=127.0.0.1;dbname=devtools"
- TEST_DB_MYSQL_HOST="127.0.0.1"
- TEST_DB_MYSQL_PORT="3306"
- TEST_DB_MYSQL_USER="root"
- TEST_DB_MYSQL_PASSWD=""
- TEST_DB_MYSQL_NAME="devtools"
- TEST_DB_MYSQL_CHARSET="utf8"
- PATH="$PATH:~/bin"
- DISPLAY=":99.0"
- PHALCON_VERSION="v3.2.0"
Expand All @@ -57,9 +64,14 @@ install:
- cd $TRAVIS_BUILD_DIR
- travis_retry composer install --prefer-dist --no-interaction

before_script:
- ln -s $PWD/phalcon.php ~/bin/phalcon

script:
- vendor/bin/codecept build
- vendor/bin/codecept run unit -v
- vendor/bin/codecept run functional -v
- vendor/bin/codecept run console -v

notifications:
email:
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
"Phalcon\\Test\\": "tests/unit",
"Phalcon\\Test\\Models\\": "tests/_data/models",
"Phalcon\\Test\\Module\\": "tests/_support/Module"
}
},
"files": [
"tests/_support/helpers.php"
]
},
"bin": ["phalcon.php"]
}
10 changes: 6 additions & 4 deletions scripts/Phalcon/Builder/Project/Micro.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ private function createHtaccessFiles()
*/
private function createIndexViewFiles()
{
$getFile = $this->options->get('templatePath') . '/project/micro/views/index.phtml';
$putFile = $this->options->get('projectPath').'app/views/index.phtml';
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';

$getFile = $this->options->get('templatePath') . '/project/micro/views/index.' . $engine;
$putFile = $this->options->get('projectPath').'app/views/index.' . $engine;
$this->generateFile($getFile, $putFile);

$getFile = $this->options->get('templatePath') . '/project/micro/views/404.phtml';
$putFile = $this->options->get('projectPath').'app/views/404.phtml';
$getFile = $this->options->get('templatePath') . '/project/micro/views/404.' . $engine;
$putFile = $this->options->get('projectPath').'app/views/404.' . $engine;
$this->generateFile($getFile, $putFile);

return $this;
Expand Down
10 changes: 6 additions & 4 deletions scripts/Phalcon/Builder/Project/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ private function createHtaccessFiles()
*/
private function createIndexViewFiles()
{
$getFile = $this->options->get('templatePath') . '/project/modules/views/index.volt';
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index.volt';
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';

$getFile = $this->options->get('templatePath') . '/project/modules/views/index.' . $engine;
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index.' . $engine;
$this->generateFile($getFile, $putFile);

$getFile = $this->options->get('templatePath') . '/project/modules/views/index/index.volt';
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index/index.volt';
$getFile = $this->options->get('templatePath') . '/project/modules/views/index/index.' . $engine;
$putFile = $this->options->get('projectPath') . 'app/modules/frontend/views/index/index.' . $engine;
$this->generateFile($getFile, $putFile);

return $this;
Expand Down
10 changes: 6 additions & 4 deletions scripts/Phalcon/Builder/Project/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ private function createHtaccessFiles()
*/
private function createIndexViewFiles()
{
$getFile = $this->options->get('templatePath') . '/project/simple/views/index.volt';
$putFile = $this->options->get('projectPath').'app/views/index.volt';
$engine = $this->options->get('templateEngine') == 'volt' ? 'volt' : 'phtml';

$getFile = $this->options->get('templatePath') . '/project/simple/views/index.' . $engine;
$putFile = $this->options->get('projectPath').'app/views/index.' . $engine;
$this->generateFile($getFile, $putFile);

$getFile = $this->options->get('templatePath') . '/project/simple/views/index/index.volt';
$putFile = $this->options->get('projectPath').'app/views/index/index.volt';
$getFile = $this->options->get('templatePath') . '/project/simple/views/index/index.' . $engine;
$putFile = $this->options->get('projectPath').'app/views/index/index.' . $engine;
$this->generateFile($getFile, $putFile);

return $this;
Expand Down
27 changes: 15 additions & 12 deletions scripts/Phalcon/Commands/Builtin/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public function getPossibleParams()
{
return [
'name=s' => 'Name of the new project',
'enable-webtools' => 'Determines if webtools should be enabled [optional]',
'directory=s' => 'Base path on which project will be created [optional]',
'type=s' => 'Type of the application to be generated (cli, micro, simple, modules)',
'template-path=s' => 'Specify a template path [optional]',
'use-config-ini' => 'Use a ini file as configuration file [optional]',
'trace' => 'Shows the trace of the framework in case of exception [optional]',
'help' => 'Shows this help [optional]',
'enable-webtools' => 'Determines if webtools should be enabled [optional]',
'directory=s' => 'Base path on which project will be created [optional]',
'type=s' => 'Type of the application to be generated (cli, micro, simple, modules)',
'template-path=s' => 'Specify a template path [optional]',
'template-engine=s' => 'Define the template engine, default phtml (phtml, volt) [optional]',
'use-config-ini' => 'Use a ini file as configuration file [optional]',
'trace' => 'Shows the trace of the framework in case of exception [optional]',
'help' => 'Shows this help [optional]',
];
}

Expand All @@ -60,19 +61,21 @@ public function getPossibleParams()
*/
public function run(array $parameters)
{
$projectName = $this->getOption(['name', 1], null, 'default');
$projectType = $this->getOption(['type', 2], null, 'simple');
$projectPath = $this->getOption(['directory', 3]);
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
$projectName = $this->getOption(['name', 1], null, 'default');
$projectType = $this->getOption(['type', 2], null, 'simple');
$projectPath = $this->getOption(['directory', 3]);
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
$enableWebtools = $this->getOption(['enable-webtools', 4], null, false);
$useConfigIni = $this->getOption('use-config-ini');
$useConfigIni = $this->getOption('use-config-ini');
$templateEngine = $this->getOption(['template-engine'], null, "phtml");

$builder = new ProjectBuilder([
'name' => $projectName,
'type' => $projectType,
'directory' => $projectPath,
'enableWebTools' => $enableWebtools,
'templatePath' => $templatePath,
'templateEngine' => $templateEngine,
'useConfigIni' => $useConfigIni
]);

Expand Down
4 changes: 2 additions & 2 deletions scripts/Phalcon/Commands/Builtin/Scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getPossibleParams()
'get-set' => 'Attributes will be protected and have setters/getters. [optional]',
'directory=s' => 'Base path on which project was created [optional]',
'template-path=s' => 'Specify a template path [optional]',
'template-engine=s' => 'Define the template engine, default php (php, volt) [optional]',
'template-engine=s' => 'Define the template engine, default phtml (phtml, volt) [optional]',
'force' => 'Forces to rewrite generated code if they already exists [optional]',
'trace' => 'Shows the trace of the framework in case of exception [optional]',
'ns-models=s' => "Model's namespace [optional]",
Expand All @@ -67,7 +67,7 @@ public function run(array $parameters)
$name = $this->getOption(['table-name', 1]);
$templatePath = $this->getOption(['template-path'], null, TEMPLATE_PATH);
$schema = $this->getOption('schema');
$templateEngine = $this->getOption(['template-engine'], null, "php");
$templateEngine = $this->getOption(['template-engine'], null, "phtml");

$scaffoldBuilder = new ScaffoldBuilder([
'name' => $name,
Expand Down
2 changes: 1 addition & 1 deletion scripts/Phalcon/Migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public static function removeCurrentVersion($options, $version)
if (isset($options['migrationsInDb']) && (bool)$options['migrationsInDb']) {
/** @var AdapterInterface $connection */
$connection = self::$_storage;
$connection->execute('DELETE FROM '. self::MIGRATION_LOG_TABLE .' WHERE version=\'' . $version . '\' LIMIT 1');
$connection->execute('DELETE FROM '. self::MIGRATION_LOG_TABLE .' WHERE version=\'' . $version . '\'');
} else {
$currentVersions = self::getCompletedVersions($options);
unset($currentVersions[(string)$version]);
Expand Down
12 changes: 9 additions & 3 deletions scripts/Phalcon/Mvc/Model/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,15 @@ public function batchDelete($tableName)
self::$_connection->begin();
self::$_connection->delete($tableName);
$batchHandler = fopen($migrationData, 'r');
while (($line = fgets($batchHandler)) !== false) {
$data = explode('|', rtrim($line), 2);
self::$_connection->delete($tableName, 'id=?', [$data[0]]);
while (($line = fgetcsv($batchHandler)) !== false) {
$values = array_map(
function ($value) {
return null === $value ? null : $value;
},
$line
);

self::$_connection->delete($tableName, 'id=?', [$values[0]]);
unset($line);
}
fclose($batchHandler);
Expand Down
14 changes: 14 additions & 0 deletions templates/project/micro/views/404.volt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Phalcon PHP Framework</title>
</head>
<body>
<div class="container">
<h1>Not found :(</h1>
<em>This page is located in views/404.volt</em>
</div>
</body>
</html>
28 changes: 28 additions & 0 deletions templates/project/micro/views/index.volt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Phalcon PHP Framework</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<div class="container">

<div class="page-header">
<h1>Congratulations!</h1>
</div>

<p>You're now flying with Phalcon. Great things are about to happen!</p>
<p>This page is located at <code>views/index.volt</code></p>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions tests/_ci/setup_dbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ psql -c 'create database devtools;' -U postgres
psql -U postgres devtools -q -f "${TRAVIS_BUILD_DIR}/tests/_data/schemas/postgresql/dump.sql"
echo -e "Done\n"

echo -e "Create MySQL database..."
mysql -u root -e "CREATE DATABASE IF NOT EXISTS devtools charset=utf8 collate=utf8_general_ci;"
cat "${TRAVIS_BUILD_DIR}/tests/_data/schemas/mysql/dump.sql" | mysql -u root devtools
echo -e "Done\n"

wait
Empty file.
Empty file.
100 changes: 100 additions & 0 deletions tests/_data/console/app/migrations/1.0.0/test_migrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

use Phalcon\Db\Column;
use Phalcon\Db\Index;
use Phalcon\Db\Reference;
use Phalcon\Mvc\Model\Migration;

/**
* Class TestMigrationsMigration_100
*/
class TestMigrationsMigration_100 extends Migration
{
/**
* Define the table structure
*
* @return void
*/
public function morph()
{
$this->morphTable('test_migrations', [
'columns' => [
new Column(
'id',
[
'type' => Column::TYPE_INTEGER,
'unsigned' => true,
'notNull' => true,
'autoIncrement' => true,
'size' => 10,
'first' => true
]
),
new Column(
'name',
[
'type' => Column::TYPE_VARCHAR,
'notNull' => true,
'size' => 45,
'after' => 'id'
]
),
new Column(
'created_at',
[
'type' => Column::TYPE_DATETIME,
'notNull' => true,
'size' => 1,
'after' => 'name'
]
),
new Column(
'updated_at',
[
'type' => Column::TYPE_DATETIME,
'notNull' => true,
'size' => 1,
'after' => 'created_at'
]
)
],
'indexes' => [
new Index('PRIMARY', ['id'], 'PRIMARY')
],
'options' => [
'TABLE_TYPE' => 'BASE TABLE',
'AUTO_INCREMENT' => '2',
'ENGINE' => 'InnoDB',
'TABLE_COLLATION' => 'utf8_general_ci'
],
]
);
}

/**
* Run the migrations
*
* @return void
*/
public function up()
{
$this->batchInsert('test_migrations', [
'id',
'name',
'created_at',
'updated_at'
]
);
}

/**
* Reverse the migrations
*
* @return void
*/
public function down()
{
$this->batchDelete('test_migrations');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1,test1,"2017-08-29 13:05:41","2017-08-29 13:05:41"
Loading

0 comments on commit 04ccd74

Please sign in to comment.