/**
  * @group DDC-3490
  *
  * @dataProvider invalidAssociationValuesDataProvider
  *
  * @param mixed $invalidValue
  */
 public function testRejectsChangeSetComputationForObjectsWithInvalidAssociationValue($invalidValue)
 {
     $metadata = $this->_emMock->getClassMetadata('Doctrine\\Tests\\Models\\Forum\\ForumUser');
     $this->_unitOfWork->setEntityPersister('Doctrine\\Tests\\Models\\Forum\\ForumUser', new EntityPersisterMock($this->_emMock, $metadata));
     $user = new ForumUser();
     $this->_unitOfWork->persist($user);
     $user->username = '******';
     $user->avatar = $invalidValue;
     $this->setExpectedException('Doctrine\\ORM\\ORMInvalidArgumentException');
     $this->_unitOfWork->computeChangeSet($metadata, $user);
 }
Exemple #2
0
 /**
  * @group DDC-2432
  */
 public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized()
 {
     $persister = $this->getMock('Doctrine\\ORM\\Persisters\\BasicEntityPersister', array('load'), array(), '', false);
     $this->uowMock->setEntityPersister('Doctrine\\Tests\\Models\\ECommerce\\ECommerceFeature', $persister);
     /* @var $proxy \Doctrine\Common\Proxy\Proxy */
     $proxy = $this->proxyFactory->getProxy('Doctrine\\Tests\\Models\\ECommerce\\ECommerceFeature', array('id' => 42));
     $persister->expects($this->atLeastOnce())->method('load')->will($this->returnValue(null));
     try {
         $cloned = clone $proxy;
         $this->fail('An exception was expected to be raised');
     } catch (EntityNotFoundException $exception) {
     }
     $this->assertFalse($proxy->__isInitialized());
     $this->assertInstanceOf('Closure', $proxy->__getInitializer(), 'The initializer wasn\'t removed');
     $this->assertInstanceOf('Closure', $proxy->__getCloner(), 'The cloner wasn\'t removed');
 }