Skip to content

Commit

Permalink
Merge pull request propelorm#474 from jaugustin/1.5
Browse files Browse the repository at this point in the history
Merge 1.4 into 1.5
  • Loading branch information
jaugustin authored Nov 10, 2017
2 parents 159522d + eedfce2 commit 89ca667
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,4 @@ before_install:
install:
- composer update ${COMPOSER_FLAGS} --prefer-source

script:
- vendor/bin/phpunit --colors
script: vendor/bin/phpunit --colors
6 changes: 3 additions & 3 deletions Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function callPhing($taskName, $properties = array())
// Add any arbitrary arguments last
foreach ($this->additionalPhingArgs as $arg) {
if (in_array($arg, array('verbose', 'debug'))) {
$bufferPhingOutput = false;
$bufferPhingOutput = true;
}

$args[] = '-'.$arg;
Expand Down Expand Up @@ -209,7 +209,7 @@ protected function callPhing($taskName, $properties = array())
$returnStatus = false;
}

if ($bufferPhingOutput) {
if ($bufferPhingOutput === false) {
ob_end_clean();
} else {
ob_end_flush();
Expand Down Expand Up @@ -393,7 +393,7 @@ protected function createBuildTimeFile($file)
<connection>
<dsn>%dsn%</dsn>
<user>%username%</user>
<password>%password%</password>
<password><![CDATA[%password%]]></password>
</connection>
</datasource>
Expand Down
15 changes: 8 additions & 7 deletions DataFixtures/Loader/AbstractDataLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected function loadDataFromArray($data = null)
continue;
}

foreach ($datas as $key => $data) {
foreach ($datas as $key => $values) {
// create a new entry in the database
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Unknown class "%s".', $class));
Expand All @@ -164,11 +164,11 @@ protected function loadDataFromArray($data = null)
);
}

if (!is_array($data)) {
if (!is_array($values)) {
throw new \InvalidArgumentException(sprintf('You must give a name for each fixture data entry (class %s).', $class));
}

foreach ($data as $name => $value) {
foreach ($values as $name => $value) {
if (is_array($value) && 's' === substr($name, -1)) {
try {
// many to many relationship
Expand Down Expand Up @@ -211,14 +211,15 @@ protected function loadDataFromArray($data = null)

if ($column->isForeignKey() && null !== $value) {
$relatedTable = $this->dbMap->getTable($column->getRelatedTableName());
if (!isset($this->object_references[$relatedTable->getClassname().'_'.$value])) {
if (isset($this->object_references[$relatedTable->getClassname().'_'.$value])) {
$value = $this
->object_references[$relatedTable->getClassname().'_'.$value]
->getByName($column->getRelatedName(), BasePeer::TYPE_COLNAME);
} else if (isset($data[$relatedTable->getClassName()])) {
throw new \InvalidArgumentException(
sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getClassname())
);
}
$value = $this
->object_references[$relatedTable->getClassname().'_'.$value]
->getByName($column->getRelatedName(), BasePeer::TYPE_COLNAME);
}
}

Expand Down
27 changes: 14 additions & 13 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
PropelBundle
============

[![Build Status](https://secure.travis-ci.org/propelorm/PropelBundle.png)](http://travis-ci.org/propelorm/PropelBundle)
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/propelorm/PropelBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=1.5)](https://travis-ci.org/propelorm/PropelBundle)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/propelorm/PropelBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This is the official implementation of [Propel](http://www.propelorm.org/) in Symfony2.
This is the official implementation of [Propel](http://www.propelorm.org/Propel/) in Symfony.

## Branching model

### Propel1 integration

The two major branches being supported are:

* The `1.5` branch contains Propel *1.6+* integration for Symfony *2.8 LTS*.
* The `1.6` branch contains Propel *1.6+* integration for Symfony *3.0*.
* The [1.5](https://github.com/propelorm/PropelBundle/tree/1.5) branch contains Propel *1.6+* integration for Symfony *2.8 LTS*. [![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=1.5)](https://travis-ci.org/propelorm/PropelBundle)
* The [1.6](https://github.com/propelorm/PropelBundle/tree/1.6) branch contains Propel *1.6+* integration for Symfony *3.x*. [![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=1.6)](https://travis-ci.org/propelorm/PropelBundle)

If you are running on an older version, you may require one of the following versions of this bundle.

* The `1.0` branch contains Propel *1.6* integration for Symfony *2.0*.
* The `1.1` branch contains Propel *1.6* integration for Symfony *2.1*.
* The `1.2` branch contains Propel *1.6* integration for Symfony *>2.1*.
* The `1.4` branch contains Propel *1.6* integration for Symfony *>2.3*.
* The [1.0](https://github.com/propelorm/PropelBundle/tree/1.0) branch contains Propel *1.6* integration for Symfony *2.0*.
* The [1.1](https://github.com/propelorm/PropelBundle/tree/1.1) branch contains Propel *1.6* integration for Symfony *2.1*.
* The [1.2](https://github.com/propelorm/PropelBundle/tree/1.2) branch contains Propel *1.6+* integration for Symfony *2.2-2.3*.
* The [1.4](https://github.com/propelorm/PropelBundle/tree/1.4) branch contains Propel *1.6+* integration for Symfony *2.4-2.7*. [![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=1.4)](https://travis-ci.org/propelorm/PropelBundle)

### Propel2 integration

* The `2.0` branch will contain `Propel2` integration for Symfony *3.0*.
* The [2.0](https://github.com/propelorm/PropelBundle/tree/2.0) branch contains `Propel2` integration for Symfony *2.5-2.8*. [![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=2.0)](https://travis-ci.org/propelorm/PropelBundle)
* The [3.0](https://github.com/propelorm/PropelBundle/tree/3.0) branch contains `Propel2` integration for Symfony *2.8-3.x*. [![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=3.0)](https://travis-ci.org/propelorm/PropelBundle)

**Note:** the `master` branch won't be updated anymore, and will trigger an `E_USER_DEPRECATED` error to notice people.

Expand All @@ -34,9 +35,9 @@ If you are running on an older version, you may require one of the following ver
* Insertion of SQL statements;
* Runtime autoloading of Propel and generated classes;
* Propel runtime initialization through the XML configuration;
* Migrations [Propel 1.6](http://www.propelorm.org/documentation/10-migrations.html);
* Reverse engineering from [existing database](http://www.propelorm.org/wiki/Documentation/1.6/Existing-Database);
* Integration to the Symfony2 Profiler;
* [Propel Migrations](http://propelorm.org/Propel/documentation/10-migrations.html);
* Reverse engineering from [existing database](http://propelorm.org/Propel/cookbook/working-with-existing-databases.html);
* Integration to the Symfony Profiler;
* Load SQL, YAML and XML fixtures;
* Create/Drop databases;
* Integration with the Form component;
Expand Down
41 changes: 37 additions & 4 deletions Tests/DataFixtures/Dumper/YamlDataDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Propel\Bundle\PropelBundle\DataFixtures\Dumper\YamlDataDumper;
use Propel\Bundle\PropelBundle\Tests\DataFixtures\TestCase;
use Symfony\Component\Config\Loader\LoaderInterface;

/**
* @author William Durand <[email protected]>
Expand Down Expand Up @@ -39,7 +40,31 @@ public function testYamlDump()
$loader = new YamlDataDumper(__DIR__.'/../../Fixtures/DataFixtures/Loader');
$loader->dump($filename);

$expected = <<<YAML
$expected = $this->getYamlForSymfonyVersion();

$result = file_get_contents($filename);
$this->assertEquals($expected, $result);
}

protected function getYamlForSymfonyVersion()
{
if (version_compare(AppKernel::VERSION, '2.8.3', '<')) {
return <<<YAML
Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor:
BookAuthor_1:
id: '1'
name: 'A famous one'
Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\Book:
Book_1:
id: '1'
name: 'An important one'
author_id: BookAuthor_1
complementary_infos: !!php/object:O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}
YAML;
}

return <<<YAML
Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor:
BookAuthor_1:
id: '1'
Expand All @@ -52,10 +77,18 @@ public function testYamlDump()
complementary_infos: !php/object:O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}
YAML;
}
}

$expectedLegacy = str_replace('!php/object', '!!php/object', $expected);
class AppKernel extends \Symfony\Component\HttpKernel\Kernel
{
public function registerBundles()
{
// TODO: Implement registerBundles() method.
}

$result = file_get_contents($filename);
$this->assertTrue(self::equalTo($expected)->evaluate($result, 'Symfony 2.8.3', true) || self::equalTo($expectedLegacy)->evaluate($result, 'Symfony 2.8.2 support', true));
public function registerContainerConfiguration(LoaderInterface $loader)
{
// TODO: Implement registerContainerConfiguration() method.
}
}
26 changes: 26 additions & 0 deletions Tests/DataFixtures/Loader/YamlDataLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ public function testYamlLoadOneToMany()
$this->assertInstanceOf('Propel\Bundle\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor', $book->getBookAuthor());
}

public function testYamlLoadOneToManyExternalReference()
{
$loader = new YamlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader');
$fixtures = <<<YAML
\Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor:
BookAuthor_1:
id: '1'
name: 'A famous one'
YAML;
$filename = $this->getTempFile($fixtures);
$loader->load(array($filename), 'default');
$fixtures = <<<YAML
\Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\Book:
Book_1:
id: '1'
name: 'An important one'
author_id: 1
YAML;
$filename = $this->getTempFile($fixtures);
$loader->load(array($filename), 'default');
$books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookQuery::create()->find($this->con);
$this->assertCount(1, $books);
$book = $books[0];
$this->assertInstanceOf('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor', $book->getBookAuthor());
}

public function testYamlLoadManyToMany()
{
$schema = <<<XML
Expand Down

0 comments on commit 89ca667

Please sign in to comment.