From 66479334d4f904996442779064987979c5ca7511 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 18 Jan 2015 00:55:40 +0100 Subject: [PATCH] #1228 DDC-3490 - computing changes of invalid objects should also fail --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 35 ++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index a0a1b8167..df7256e44 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -255,7 +255,33 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase * * @param mixed $invalidValue */ - public function testRejectsInvalidAssociationValue($invalidValue) + public function testRejectsPersistenceOfObjectsWithInvalidAssociationValue($invalidValue) + { + $this->_unitOfWork->setEntityPersister( + 'Doctrine\Tests\Models\Forum\ForumUser', + new EntityPersisterMock( + $this->_emMock, + $this->_emMock->getClassMetadata('Doctrine\Tests\Models\Forum\ForumUser') + ) + ); + + $user = new ForumUser(); + $user->username = 'John'; + $user->avatar = $invalidValue; + + $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException'); + + $this->_unitOfWork->persist($user); + } + + /** + * @group DDC-3490 + * + * @dataProvider invalidAssociationValuesDataProvider + * + * @param mixed $invalidValue + */ + public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue($invalidValue) { $metadata = $this->_emMock->getClassMetadata('Doctrine\Tests\Models\Forum\ForumUser'); @@ -264,14 +290,15 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase new EntityPersisterMock($this->_emMock, $metadata) ); - // Create a test user - $user = new ForumUser(); + $user = new ForumUser(); + + $this->_unitOfWork->persist($user); + $user->username = 'John'; $user->avatar = $invalidValue; $this->setExpectedException('Doctrine\ORM\ORMInvalidArgumentException'); - $this->_unitOfWork->persist($user); $this->_unitOfWork->computeChangeSet($metadata, $user); }