Skip to content

Commit

Permalink
merged branch willdurand/propel-transformer (PR #4024)
Browse files Browse the repository at this point in the history
Commits
-------

9447b84 [Propel1] Allowed PropelObjectCollection only in CollectionToArrayTransformer
e43d0fa reverse transform into PropelObjectCollection

Discussion
----------

Propel transformer

Prefer this PR over #3966
  • Loading branch information
fabpot committed Apr 20, 2012
2 parents 56a4ab7 + 9447b84 commit 9d22eb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bridge\Propel1\Form\DataTransformer;

use \PropelCollection;
use \PropelObjectCollection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;

Expand All @@ -29,16 +29,16 @@ public function transform($collection)
return array();
}

if (!$collection instanceof PropelCollection) {
throw new UnexpectedTypeException($collection, '\PropelCollection');
if (!$collection instanceof PropelObjectCollection) {
throw new UnexpectedTypeException($collection, '\PropelObjectCollection');
}

return $collection->getData();
}

public function reverseTransform($array)
{
$collection = new PropelCollection();
$collection = new PropelObjectCollection();

if ('' === $array || null === $array) {
return $collection;
Expand Down
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bridge\Propel1\Tests\Form\DataTransformer;

use \PropelCollection;
use \PropelObjectCollection;
use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Bridge\Propel1\Tests\Propel1TestCase;

Expand All @@ -32,7 +32,7 @@ protected function setUp()

public function testTransform()
{
$result = $this->transformer->transform(new PropelCollection());
$result = $this->transformer->transform(new PropelObjectCollection());

$this->assertTrue(is_array($result));
$this->assertEquals(0, count($result));
Expand All @@ -49,14 +49,14 @@ public function testTransformWithNull()
/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testTransformThrowsExceptionIfNotPropelCollection()
public function testTransformThrowsExceptionIfNotPropelObjectCollection()
{
$this->transformer->transform(new DummyObject());
}

public function testTransformWithData()
{
$coll = new PropelCollection();
$coll = new PropelObjectCollection();
$coll->setData(array('foo', 'bar'));

$result = $this->transformer->transform($coll);
Expand All @@ -71,15 +71,15 @@ public function testReverseTransformWithNull()
{
$result = $this->transformer->reverseTransform(null);

$this->assertInstanceOf('\PropelCollection', $result);
$this->assertInstanceOf('\PropelObjectCollection', $result);
$this->assertEquals(0, count($result->getData()));
}

public function testReverseTransformWithEmptyString()
{
$result = $this->transformer->reverseTransform('');

$this->assertInstanceOf('\PropelCollection', $result);
$this->assertInstanceOf('\PropelObjectCollection', $result);
$this->assertEquals(0, count($result->getData()));
}

Expand All @@ -98,7 +98,7 @@ public function testReverseTransformWithData()
$result = $this->transformer->reverseTransform($inputData);
$data = $result->getData();

$this->assertInstanceOf('\PropelCollection', $result);
$this->assertInstanceOf('\PropelObjectCollection', $result);

$this->assertTrue(is_array($data));
$this->assertEquals(2, count($data));
Expand Down

0 comments on commit 9d22eb6

Please sign in to comment.