[Propel1] Allowed PropelObjectCollection only in CollectionToArrayTransformer

This commit is contained in:
William DURAND 2012-04-20 09:32:01 +02:00
parent e43d0fa0fd
commit 9447b84acb
2 changed files with 6 additions and 7 deletions

View File

@ -11,7 +11,6 @@
namespace Symfony\Bridge\Propel1\Form\DataTransformer;
use \PropelCollection;
use \PropelObjectCollection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
@ -30,8 +29,8 @@ class CollectionToArrayTransformer implements DataTransformerInterface
return array();
}
if (!$collection instanceof PropelCollection) {
throw new UnexpectedTypeException($collection, '\PropelCollection');
if (!$collection instanceof PropelObjectCollection) {
throw new UnexpectedTypeException($collection, '\PropelObjectCollection');
}
return $collection->getData();

View File

@ -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;
@ -32,7 +32,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
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));
@ -49,14 +49,14 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
/**
* @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);