Skip to content

Commit

Permalink
try and merge in propelorm#1086
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGoodwin committed Sep 18, 2020
2 parents 0f32375 + 5aa667c commit ddfbf17
Show file tree
Hide file tree
Showing 177 changed files with 472 additions and 363 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ language: php
services:
- mysql

#services: docker

branches:
only:
- master

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.4

env:
- DB=mysql DB_USER=root
Expand All @@ -29,3 +31,5 @@ before_script:

script: vendor/bin/phpunit

#script:
# bash docker/run.sh
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,25 @@
},
"include-path": ["runtime/lib", "generator/lib"],
"require": {
"php": ">=5.2.4",
"php": "^7.1",
"phing/phing": "~2.4"

},
"require-dev": {
"pear-pear.php.net/pear_packagefilemanager2" : "@stable",
"phpunit/phpunit": "~4.0||~5.0"
"phpunit/phpunit": "~8|~9",
"phpcompatibility/php-compatibility": "^9.3",
"squizlabs/php_codesniffer": "^3.5"
},
"repositories": [
{
"type": "pear",
"url": "https://pear.php.net"
}
],
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"]
"bin": ["generator/bin/propel-gen", "generator/bin/propel-gen.bat"],
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
}
}
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM thecodingmachine/php:7.4-v3-cli
USER root
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8

USER docker
ENV LANG en_US.UTF-8

26 changes: 26 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3'
services:
php:
build:
context: .
dockerfile: Dockerfile
working_dir: /usr/src/app
command: phpunit
volumes:
- ../:/usr/src/app
environment:
- PHP_EXTENSIONS=intl pdo_sqlite sqlite3
- STARTUP_COMMAND_1=composer install
- STARTUP_COMMAND_2=bash test/reset_tests.sh

db:
image: percona
command: >
mysqld
--sql-mode="NO_ENGINE_SUBSTITUTION"
--character-set-server="utf8"
--collation-server="utf8_unicode_ci"
--default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
4 changes: 4 additions & 0 deletions docker/reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mysql -u root -e 'SET FOREIGN_KEY_CHECKS = 0; DROP DATABASE IF EXISTS test; DROP SCHEMA IF EXISTS second_hand_books; DROP SCHEMA IF EXISTS contest; DROP DATABASE IF EXISTS reverse_bookstore; DROP SCHEMA IF EXISTS bookstore_schemas; SET FOREIGN_KEY_CHECKS = 1;'
mysql -u root -e 'CREATE DATABASE test; CREATE SCHEMA bookstore_schemas; CREATE SCHEMA contest; CREATE SCHEMA second_hand_books; CREATE DATABASE reverse_bookstore;'
7 changes: 7 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
cd docker
docker-compose up -d db
sleep 20
docker-compose exec -T db bash < reset.sh
docker-compose build
docker-compose run php
3 changes: 3 additions & 0 deletions generator/lib/builder/om/PHP5ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
try {
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
\$row = \$stmt->fetch(PDO::FETCH_NUM);
if (\$row === false) {
\$row = [null]; // for backward compatibility
}
\$stmt->closeCursor();";
}

Expand Down
3 changes: 3 additions & 0 deletions generator/lib/builder/om/PHP5ObjectNoCollectionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ protected function addLazyLoaderBody(&$script, Column $col)
try {
\$stmt = " . $this->getPeerClassname() . "::doSelectStmt(\$c, \$con);
\$row = \$stmt->fetch(PDO::FETCH_NUM);
if (\$row === false) {
\$row = [null]; // for backward compatibility
}
\$stmt->closeCursor();";

if ($col->getType() === PropelTypes::CLOB && $this->getPlatform() instanceof OraclePlatform) {
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/model/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function addColumn($data)
}
} else {
$attrib = $data;
$name = $attrib["name"];
$name = $attrib["name"] ?? null;
$this->indexColumns[] = $name;
if (isset($attrib["size"])) {
$this->indexColumnSizes[$name] = $attrib["size"];
Expand Down
2 changes: 1 addition & 1 deletion generator/lib/platform/DefaultPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ public function getPhpArrayString($stringValue)
$values[] = trim($v);
}

$value = implode($values, ' | ');
$value = implode(' | ', $values);
if (empty($value) || ' | ' === $value) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="test/bootstrap.php"
>

Expand Down
13 changes: 11 additions & 2 deletions runtime/lib/formatter/PropelArrayFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ public function format(PDOStatement $stmt)
} else {
$collection = array();
}

/**
* @var $collection PropelArrayCollection
*/

if ($this->isWithOneToMany() && $this->hasLimit) {
throw new PropelException('Cannot use limit() in conjunction with with() on a one-to-many relationship. Please remove the with() call, or the limit() call.');
}
$items = [];

$data = [];

while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
$object = &$this->getStructuredArrayFromRow($row);
if ($object) {
$items[] =& $object;
$data[] = &$object;
}
}

Expand All @@ -50,6 +57,8 @@ public function format(PDOStatement $stmt)
$this->alreadyHydratedObjects = array();
$stmt->closeCursor();

$collection->setData($data);

return $collection;
}

Expand Down
3 changes: 2 additions & 1 deletion runtime/lib/map/TableMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,10 @@ public function setPrefix($prefix)
*/
protected function hasPrefix($data)
{
if(!$this->prefix) {
if (!$this->prefix) {
return false;
}

return (strpos($data, $this->prefix) === 0);
}

Expand Down
12 changes: 4 additions & 8 deletions runtime/lib/parser/yaml/sfYamlInline.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ public static function load($value)
return '';
}

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
}
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');

switch ($value[0]) {
case '[':
Expand Down Expand Up @@ -124,10 +122,8 @@ protected static function dumpArray($value)
{
// array
$keys = array_keys($value);
if (
(1 == count($keys) && '0' == $keys[0])
||
(count($keys) > 1 && array_reduce($keys, create_function('$v,$w', 'return (integer) $v + $w;'), 0) == count($keys) * (count($keys) - 1) / 2))

if (count($value) > 0 && array_values($value) === $value)
{
$output = array();
foreach ($value as $val) {
Expand Down
6 changes: 2 additions & 4 deletions runtime/lib/parser/yaml/sfYamlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ public function parse($value)
$this->currentLine = '';
$this->lines = explode("\n", $this->cleanup($value));

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
}
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');

$data = array();
while ($this->moveToNextLine()) {
Expand Down
2 changes: 1 addition & 1 deletion runtime/lib/validator/NotMatchValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class NotMatchValidator implements BasicValidator
private function prepareRegexp($exp)
{
// remove surrounding '/' marks so that they don't get escaped in next step
if ($exp{0} !== '/' || $exp{strlen($exp) - 1} !== '/') {
if ($exp[0] !== '/' || $exp[strlen($exp) - 1] !== '/') {
$exp = '/' . $exp . '/';
}

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/bookstore/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore
propel.database = mysql
propel.database.url = mysql:dbname=test
propel.database.url = mysql:host=db;dbname=test
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting = true
propel.schema.autoPrefix = true
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/bookstore/runtime-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=test</dsn>
<dsn>mysql:host=db;dbname=test</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand Down Expand Up @@ -51,7 +51,7 @@
<adapter>mysql</adapter>
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=test</dsn>
<dsn>mysql:host=db;dbname=test</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand All @@ -73,7 +73,7 @@
<adapter>mysql</adapter>
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=test</dsn>
<dsn>mysql:host=db;dbname=test</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/namespaced/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore_namespaced
propel.database = mysql
propel.database.url = mysql:dbname=test
propel.database.url = mysql:host=db;dbname=test
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting=true

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/namespaced/runtime-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<!-- Connection parameters. See PDO documentation for DSN format and available option constants. -->
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=test</dsn>
<dsn>mysql:host=db;dbname=test</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/reverse/mysql/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
propel.project = reverse_bookstore

propel.database = mysql
propel.database.url = mysql:dbname=reverse_bookstore
propel.database.url = mysql:host=db;dbname=reverse_bookstore

# For MySQL or Oracle, you also need to specify username & password
propel.database.user = root
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/reverse/mysql/runtime-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<adapter>mysql</adapter>
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=reverse_bookstore</dsn>
<dsn>mysql:host=db;dbname=reverse_bookstore</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/schemas/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

propel.project = bookstore
propel.database = mysql
propel.database.url = mysql:dbname=test
propel.database.url = mysql:host=db;dbname=test
propel.database.user = root
propel.mysql.tableType = InnoDB
propel.disableIdentifierQuoting = true
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/schemas/runtime-conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<adapter>mysql</adapter>
<connection>
<classname>DebugPDO</classname>
<dsn>mysql:dbname=test</dsn>
<dsn>mysql:host=db;dbname=test</dsn>
<!--
For MySQL and Oracle you must specify username + password separate from DSN:
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @version $Revision$
* @package generator.behavior
*/
class AlternativeCodingStandardsBehaviorTest extends PHPUnit_Framework_TestCase
class AlternativeCodingStandardsBehaviorTest extends \PHPUnit\Framework\TestCase
{
public function convertBracketsNewlineDataProvider()
{
Expand Down
5 changes: 3 additions & 2 deletions test/testsuite/generator/behavior/DelegateBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
* @version $Revision$
* @package generator.behavior
*/
class DelegateBehaviorTest extends PHPUnit_Framework_TestCase
class DelegateBehaviorTest extends \PHPUnit\Framework\TestCase
{

public function setUp()
protected function setUp(): void
{
if (!class_exists('DelegateDelegate')) {
$schema = <<<EOF
Expand Down Expand Up @@ -175,6 +175,7 @@ public function testAModelCanHaveSeveralDelegates()
*/
public function testAModelCannotHaveCascadingDelegates()
{
$this->expectException(PropelException::class);
$main = new DelegateMain();
$main->setSummary('bar');
$main->setBody('baz');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
require_once __DIR__.'/../../../fixtures/generator/behavior/Foobar.php';

class NamespacedBehaviorTest extends PHPUnit_Framework_TestCase
class NamespacedBehaviorTest extends \PHPUnit\Framework\TestCase
{
/**
* test if issue 425 is resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class SoftDeleteBehaviorTest extends BookstoreTestBase
{

protected function setUp()
protected function setUp(): void
{
parent::setUp();
Table4Peer::disableSoftDelete();
Expand Down
4 changes: 2 additions & 2 deletions test/testsuite/generator/behavior/TableBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* @author Francois Zaninotto
* @package generator.behavior
*/
class TableBehaviorTest extends PHPUnit_Framework_TestCase
class TableBehaviorTest extends \PHPUnit\Framework\TestCase
{
protected function setUp()
protected function setUp(): void
{
parent::setUp();
set_include_path(get_include_path() . PATH_SEPARATOR . "fixtures/bookstore/build/classes");
Expand Down
Loading

0 comments on commit ddfbf17

Please sign in to comment.