Permalink
Browse files

Added failing tests for object and array type columns, caused by object

reuse via the PropelOnDemandFormatter.
  • Loading branch information...
1 parent af6994e commit 33acfaa81395c875e0809b6de937296872343c8b @mhitza mhitza committed with willdurand Jan 30, 2012
@@ -127,4 +127,24 @@ public function testValueIsPersisted()
$e = ComplexColumnTypeEntity2Query::create()->findOne();
$this->assertEquals($value, $e->getTags(), 'array columns are persisted');
}
+
+ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter()
+ {
+ ComplexColumnTypeEntity2Query::create()->deleteAll();
+ $e = new ComplexColumnTypeEntity2();
+ $e->setTags(array(1,2));
+ $e->save();
+ $e = new ComplexColumnTypeEntity2();
+ $e->setTags(array(3,4));
+ $e->save();
+ $q = ComplexColumnTypeEntity2Query::create()
+ ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
+ ->find();
+
+ $tags = array();
+ foreach($q as $e) {
+ $tags[] = $e->getTags();
+ }
+ $this->assertNotEquals($tags[0], $tags[1]);
+ }
}
@@ -19,17 +19,23 @@
*/
class GeneratedObjectObjectColumnTypeTest extends PHPUnit_Framework_TestCase
{
- public function testObjectColumnType()
+ public function setUp()
{
- $schema = <<<EOF
+ if(!class_exists('ComplexColumnTypeEntity1')) {
+ $schema = <<<EOF
<database name="generated_object_complex_type_test_1">
<table name="complex_column_type_entity_1">
<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
<column name="bar" type="OBJECT" />
</table>
</database>
EOF;
- PropelQuickBuilder::buildSchema($schema);
+ PropelQuickBuilder::buildSchema($schema);
+ }
+ }
+
+ public function testObjectColumnType()
+ {
$e = new ComplexColumnTypeEntity1();
$this->assertNull($e->getBar(), 'object columns are null by default');
$c = new FooColumnValue();
@@ -44,6 +50,26 @@ public function testObjectColumnType()
$e = ComplexColumnTypeEntity1Query::create()->findOne();
$this->assertEquals($c, $e->getBar(), 'object columns are persisted');
}
+
+ public function testGetterDoesNotKeepValueBetweenTwoHydrationsWhenUsingOnDemandFormatter()
+ {
+ ComplexColumnTypeEntity1Query::create()->deleteAll();
+ $e = new ComplexColumnTypeEntity1();
+ $e->setBar((object)array(1,2));
+ $e->save();
+ $e = new ComplexColumnTypeEntity1();
+ $e->setBar((object)array(3,4));
+ $e->save();
+ $q = ComplexColumnTypeEntity1Query::create()
+ ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)
+ ->find();
+
+ $objects = array();
+ foreach($q as $e) {
+ $objects[] = $e->getBar();
+ }
+ $this->assertNotEquals($objects[0], $objects[1]);
+ }
}
class FooColumnValue

0 comments on commit 33acfaa

Please sign in to comment.