Commit b8090c99 authored by romanb's avatar romanb

[2.0] Moved locking tests into Functional namespace. Fixed several missing...

[2.0] Moved locking tests into Functional namespace. Fixed several missing flush() calls in some functional association tests. Reordered DELETE statements for ecommerce model tests in OrmFunctionalTestCase in order to maintain referential integrity. Fixed issue with bi-directional self-referencing one-one associations. Some other small improvements and cosmetics. Small hydration performance improvement through inlining method call in UnitOfWork::createEntity().
parent 20858236
<?php
namespace Doctrine\ORM\Event;
class LifecycleEventArgs extends \Doctrine\Common\EventArgs
{
private $_em;
private $_entity;
public function __construct($entity, \Doctrine\ORM\EntityManager $em)
{
$this->_entity = $entity;
}
public function getEntity()
{
return $this->_entity;
}
public function getEntityManager()
{
return $this->_em;
}
}
\ No newline at end of file
......@@ -39,6 +39,6 @@ final class Events
const postInsert = 'postInsert';
const preUpdate = 'preUpdate';
const postUpdate = 'postUpdate';
const load = 'load';
const postLoad = 'postLoad';
const loadClassMetadata = 'loadClassMetadata';
}
\ No newline at end of file
......@@ -283,8 +283,8 @@ class ObjectHydrator extends AbstractHydrator
if (isset($targetClass->inverseMappings[$property])) {
$sourceProp = $targetClass->inverseMappings[$property]->sourceFieldName;
$targetClass->reflFields[$sourceProp]->setValue($entity2, $entity1);
} else if ($class === $targetClass) {
// Special case: self-referencing one-one on the same class
} else if ($class === $targetClass && $relation->mappedByFieldName) {
// Special case: bi-directional self-referencing one-one on the same class
$targetClass->reflFields[$property]->setValue($entity2, $entity1);
}
} else {
......
......@@ -293,14 +293,6 @@ final class ClassMetadata
* @var array
*/
public $primaryTable;
/**
* The cached lifecycle listeners. There is only one instance of each
* listener class at any time.
*
* @var array
*/
public $lifecycleListenerInstances = array();
/**
* The registered lifecycle callbacks for entities of this class.
......@@ -309,13 +301,6 @@ final class ClassMetadata
*/
public $lifecycleCallbacks = array();
/**
* The registered lifecycle listeners for entities of this class.
*
* @var array
*/
public $lifecycleListeners = array();
/**
* The association mappings. All mappings, inverse and owning side.
*
......@@ -398,14 +383,14 @@ final class ClassMetadata
public $inheritedAssociationFields = array();
/**
* A flag for whether or not the model is to be versioned with optimistic locking
* A flag for whether or not instances of this class are to be versioned with optimistic locking.
*
* @var boolean $isVersioned
*/
public $isVersioned;
/**
* The name of the field which stores the version information
* The name of the field which is used for versioning in optimistic locking (if any).
*
* @var mixed $versionField
*/
......@@ -415,7 +400,7 @@ final class ClassMetadata
* Initializes a new ClassMetadata instance that will hold the object-relational mapping
* metadata of the class with the given name.
*
* @param string $entityName Name of the entity class the new instance is used for.
* @param string $entityName The name of the entity class the new instance is used for.
*/
public function __construct($entityName)
{
......@@ -1531,56 +1516,31 @@ final class ClassMetadata
*/
public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
{
foreach ($this->getLifecycleCallbacks($lifecycleEvent) as $callback) {
foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) {
$entity->$callback();
}
foreach ($this->getLifecycleListeners($lifecycleEvent) as $className => $callback) {
if ( ! isset($this->lifecycleListenerInstances[$className])) {
$this->lifecycleListenerInstances[$className] = new $className;
}
$this->lifecycleListenerInstances[$className]->$callback($entity);
}
}
/**
* Gets the registered lifecycle callbacks for an event.
*
* @param string $event
* @return array
* Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event.
*
* @param string $lifecycleEvent
* @return boolean
*/
public function getLifecycleCallbacks($event)
public function hasLifecycleCallbacks($lifecycleEvent)
{
return isset($this->lifecycleCallbacks[$event]) ?
$this->lifecycleCallbacks[$event] : array();
return isset($this->lifecycleCallbacks[$lifecycleEvent]);
}
/**
* Gets the registered lifecycle listeners for an event.
* Gets the registered lifecycle callbacks for an event.
*
* @param string $event
* @return array
*/
public function getLifecycleListeners($event)
{
return isset($this->lifecycleListeners[$event]) ?
$this->lifecycleListeners[$event] : array();
}
/**
* Adds a lifecycle listener for entities of this class.
*
* Note: If the same listener class is registered more than once, the old
* one will be overridden.
*
* @param string $listenerClass
* @param array $callbacks
*/
public function addLifecycleListener($listenerClass, array $callbacks)
public function getLifecycleCallbacks($event)
{
$this->lifecycleListeners[$event][$listenerClass] = array();
foreach ($callbacks as $method => $event) {
$this->lifecycleListeners[$event][$listenerClass][] = $method;
}
return isset($this->lifecycleCallbacks[$event]) ? $this->lifecycleCallbacks[$event] : array();
}
/**
......@@ -1594,12 +1554,7 @@ final class ClassMetadata
*/
public function addLifecycleCallback($callback, $event)
{
if ( ! isset($this->lifecycleCallbacks[$event])) {
$this->lifecycleCallbacks[$event] = array();
}
if ( ! in_array($callback, $this->lifecycleCallbacks[$event])) {
$this->lifecycleCallbacks[$event][$callback] = $callback;
}
$this->lifecycleCallbacks[$event][] = $callback;
}
/**
......@@ -1771,20 +1726,44 @@ final class ClassMetadata
{
$this->sequenceGeneratorDefinition = $definition;
}
public function isVersioned($bool = null)
/**
* Checks whether this class is versioned for optimistic locking.
*
* @return boolean TRUE if this class is versioned for optimistic locking, FALSE otherwise.
*/
public function isVersioned()
{
if ( ! is_null($bool)) {
$this->isVersioned = $bool;
}
return $this->isVersioned;
}
/**
* Sets whether this class is to be versioned for optimistic locking.
*
* @param boolean $bool
*/
public function setVersioned($bool)
{
$this->isVersioned = $bool;
}
/**
* Gets the name of the field that is used for versioning if this class is versioned
* for optimistic locking.
*
* @return string
*/
public function getVersionField()
{
return $this->versionField;
}
/**
* Sets the name of the field that is to be used for versioning if this class is
* versioned for optimistic locking.
*
* @param string $versionField
*/
public function setVersionField($versionField)
{
$this->versionField = $versionField;
......
......@@ -26,7 +26,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\ORM\Events;
/**
* The metadata factory is used to create ClassMetadata objects that contain all the
* The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
* metadata mapping informations of a class which describes how a class should be mapped
* to a relational database.
*
......@@ -35,7 +35,7 @@ use Doctrine\ORM\Events;
* @version $Revision$
* @link www.doctrine-project.org
* @since 2.0
* @todo Support for mapped superclasses (@DoctrineMappedSuperclass)
* @todo Support for mapped superclasses (@MappedSuperclass)
*/
class ClassMetadataFactory
{
......@@ -114,7 +114,8 @@ class ClassMetadataFactory
/**
* Sets the metadata descriptor for a specific class.
* This is only useful in very special cases, like when generating proxy classes.
*
* NOTE: This is only useful in very special cases, like when generating proxy classes.
*
* @param string $className
* @param ClassMetadata $class
......@@ -162,7 +163,7 @@ class ClassMetadataFactory
$this->_addInheritedFields($class, $parent);
$this->_addInheritedRelations($class, $parent);
$class->setIdentifier($parent->identifier);
$class->isVersioned($parent->isVersioned);
$class->setVersioned($parent->isVersioned);
$class->setVersionField($parent->versionField);
}
......@@ -261,8 +262,8 @@ class ClassMetadataFactory
*/
private function _generateStaticSql($class)
{
if ($versioned = $class->isVersioned()) {
$versionField = $class->getVersionField();
if ($versioned = $class->isVersioned) {
$versionField = $class->versionField;
}
// Generate INSERT SQL
......
......@@ -157,7 +157,7 @@ class AnnotationDriver implements Driver
$metadata->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $generatedValueAnnot->strategy));
}
if ($versionAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\Version')) {
$metadata->isVersioned(true);
$metadata->setVersioned(true);
$metadata->setVersionField($mapping['fieldName']);
if ( ! isset($mapping['default'])) {
......@@ -177,7 +177,7 @@ class AnnotationDriver implements Driver
'initialValue' => $seqGeneratorAnnot->initialValue
));
} else if ($tblGeneratorAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\TableGenerator')) {
throw new DoctrineException("DoctrineTableGenerator not yet implemented.");
throw DoctrineException::tableIdGeneratorNotImplemented();
}
} else if ($oneToOneAnnot = $this->_reader->getPropertyAnnotation($property, 'Doctrine\ORM\Mapping\OneToOne')) {
$mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
......
......@@ -101,4 +101,15 @@ final class SequenceGenerator extends \Doctrine\Common\Annotations\Annotation {
public $initialValue = 1;
}
final class ChangeTrackingPolicy extends \Doctrine\Common\Annotations\Annotation {}
final class DoctrineX extends \Doctrine\Common\Annotations\Annotation {}
\ No newline at end of file
/* Annotations for lifecycle callbacks */
final class PreSave extends \Doctrine\Common\Annotations\Annotation {}
final class PostSave extends \Doctrine\Common\Annotations\Annotation {}
final class PreUpdate extends \Doctrine\Common\Annotations\Annotation {}
final class PostUpdate extends \Doctrine\Common\Annotations\Annotation {}
final class PreDelete extends \Doctrine\Common\Annotations\Annotation {}
final class PostDelete extends \Doctrine\Common\Annotations\Annotation {}
final class PostLoad extends \Doctrine\Common\Annotations\Annotation {}
/* Generic annotation for Doctrine extensions */
final class DoctrineX extends \Doctrine\Common\Annotations\Annotation {}
......@@ -87,7 +87,11 @@ class OneToOneMapping extends AssociationMapping
{
parent::_validateAndCompleteMapping($mapping);
if ($this->isOwningSide()) {
if (isset($mapping['joinColumns']) && $mapping['joinColumns']) {
$this->isOwningSide = true;
}
if ($this->isOwningSide) {
if ( ! isset($mapping['joinColumns'])) {
throw MappingException::invalidMapping($this->sourceFieldName);
}
......
......@@ -132,20 +132,13 @@ class StandardEntityPersister
$primaryTableName = $this->_class->primaryTable['name'];
$sqlLogger = $this->_conn->getConfiguration()->getSqlLogger();
$hasPreInsertListeners = $this->_evm->hasListeners(Events::preInsert);
$hasPostInsertListeners = $this->_evm->hasListeners(Events::postInsert);
foreach ($this->_queuedInserts as $entity) {
$insertData = array();
$this->_prepareData($entity, $insertData, true);
if ($hasPreInsertListeners) {
$this->_preInsert($entity);
}
$paramIndex = 1;
if ($sqlLogger) {
//TODO: Log type
$params = array();
foreach ($insertData[$primaryTableName] as $value) {
$params[$paramIndex] = $value;
......@@ -170,10 +163,6 @@ class StandardEntityPersister
if ($isVersioned) {
$this->_assignDefaultVersionValue($this->_class, $entity, $id);
}
if ($hasPostInsertListeners) {
$this->_postInsert($entity);
}
}
$stmt->closeCursor();
......@@ -191,7 +180,7 @@ class StandardEntityPersister
*/
protected function _assignDefaultVersionValue($class, $entity, $id)
{
$versionField = $this->_class->getVersionField();
$versionField = $this->_class->versionField;
$identifier = $this->_class->getIdentifierColumnNames();
$versionFieldColumnName = $this->_class->getColumnName($versionField);
......@@ -246,8 +235,8 @@ class StandardEntityPersister
$set[] = $this->_conn->quoteIdentifier($columnName) . ' = ?';
}
if ($isVersioned = $this->_class->isVersioned()) {
$versionField = $this->_class->getVersionField();
if ($isVersioned = $this->_class->isVersioned) {
$versionField = $this->_class->versionField;
$identifier = $this->_class->getIdentifier();
$versionFieldColumnName = $this->_class->getColumnName($versionField);
$where[$versionFieldColumnName] = $entity->version;
......@@ -339,8 +328,8 @@ class StandardEntityPersister
$platform = $this->_conn->getDatabasePlatform();
$uow = $this->_em->getUnitOfWork();
if ($versioned = $this->_class->isVersioned()) {
$versionField = $this->_class->getVersionField();
if ($versioned = $this->_class->isVersioned) {
$versionField = $this->_class->versionField;
}
foreach ($uow->getEntityChangeSet($entity) as $field => $change) {
......@@ -359,9 +348,8 @@ class StandardEntityPersister
continue;
}
// Special case: One-one self-referencing of the same class with IDENTITY type key generation.
if ($this->_class->isIdGeneratorIdentity() && $newVal !== null &&
$assocMapping->sourceEntityName == $assocMapping->targetEntityName) {
// Special case: One-one self-referencing of the same class.
if ($newVal !== null && $assocMapping->sourceEntityName == $assocMapping->targetEntityName) {
$oid = spl_object_hash($newVal);
$isScheduledForInsert = $uow->isRegisteredNew($newVal);
if (isset($this->_queuedInserts[$oid]) || $isScheduledForInsert) {
......@@ -448,6 +436,8 @@ class StandardEntityPersister
}
if ( ! $this->_em->getConfiguration()->getAllowPartialObjects()) {
// Partial objects not allowed, so make sure we put in proxies and
// empty collections respectively.
foreach ($this->_class->associationMappings as $field => $assoc) {
if ($assoc->isOneToOne()) {
if ($assoc->isLazilyFetched) {
......@@ -455,7 +445,7 @@ class StandardEntityPersister
$proxy = $this->_em->getProxyGenerator()->getAssociationProxy($entity, $assoc);
$this->_class->reflFields[$field]->setValue($entity, $proxy);
} else {
//TODO: Eager fetch?
//TODO: Eager fetch
}
} else {
// Inject collection
......@@ -492,50 +482,4 @@ class StandardEntityPersister
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
. ' WHERE ' . $conditionSql;
}
/**
* Dispatches the preInsert event for the given entity.
*
* @param object $entity
*/
final protected function _preInsert($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreInsertUpdateEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preInsert, $eventArgs);
}
/**
* Dispatches the postInsert event for the given entity.
*
* @param object $entity
*/
final protected function _postInsert($entity)
{
$this->_evm->dispatchEvent(Events::postInsert);
}
/**
* Dispatches the preUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _preUpdate($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreInsertUpdateEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preUpdate, $eventArgs);
}
/**
* Dispatches the postUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _postUpdate($entity)
{
$this->_evm->dispatchEvent(Events::postUpdate);
}
}
This diff is collapsed.
......@@ -27,7 +27,7 @@ class CompanyPerson
*/
private $name;
/**
* @OneToOne(targetEntity="CompanyPerson")
* @OneToOne(targetEntity="CompanyPerson", mappedBy="spouse")
* @JoinColumn(name="spouse_id", referencedColumnName="id")
*/
private $spouse;
......
......@@ -33,6 +33,7 @@ class ECommerceCustomer
* Example of a one-one self referential association. A mentor can follow
* only one customer at the time, while a customer can choose only one
* mentor. Not properly appropriate but it works.
*
* @OneToOne(targetEntity="ECommerceCustomer", cascade={"save"})
* @JoinColumn(name="mentor_id", referencedColumnName="id")
*/
......
......@@ -2,15 +2,6 @@
namespace Doctrine\Tests\ORM;
use Doctrine\Tests\ORM\Associations;
use Doctrine\Tests\ORM\Cache;
use Doctrine\Tests\ORM\Entity;
use Doctrine\Tests\ORM\Hydration;
use Doctrine\Tests\ORM\Mapping;
use Doctrine\Tests\ORM\Query;
use Doctrine\Tests\ORM\Ticket;
use Doctrine\Tests\ORM\Functional;
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_AllTests::main');
}
......@@ -42,7 +33,6 @@ class AllTests
$suite->addTest(Mapping\AllTests::suite());
$suite->addTest(Functional\AllTests::suite());
$suite->addTest(Id\AllTests::suite());
$suite->addTest(Locking\AllTests::suite());
return $suite;
}
......
......@@ -35,6 +35,8 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\OneToManySelfReferentialAssociationTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\ManyToManySelfReferentialAssociationTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\ReferenceProxyTest');
$suite->addTest(Locking\AllTests::suite());
return $suite;
}
......
......@@ -26,6 +26,7 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$user->username = 'romanb';
$user->status = 'developer';
$this->_em->save($user);
$this->assertTrue(is_numeric($user->id));
$this->assertTrue($this->_em->contains($user));
......
......@@ -21,7 +21,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
}
public function testCRUD()
{
{
$person = new CompanyPerson;
$person->setName('Roman S. Borschel');
......
<?php
namespace Doctrine\Tests\ORM\Locking;
namespace Doctrine\Tests\ORM\Functional\Locking;
if (!defined('PHPUnit_MAIN_METHOD')) {
define('PHPUnit_MAIN_METHOD', 'Orm_Locking_AllTests::main');
define('PHPUnit_MAIN_METHOD', 'Orm_Functional_Locking_AllTests::main');
}
require_once __DIR__ . '/../../TestInit.php';
require_once __DIR__ . '/../../../TestInit.php';
class AllTests
{
......@@ -17,14 +17,14 @@ class AllTests
public static function suite()
{
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Locking');
$suite = new \Doctrine\Tests\DoctrineTestSuite('Doctrine Orm Functional Locking');
$suite->addTestSuite('Doctrine\Tests\ORM\Locking\OptimisticTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Functional\Locking\OptimisticTest');
return $suite;
}
}
if (PHPUnit_MAIN_METHOD == 'Orm_Locking_AllTests::main') {
if (PHPUnit_MAIN_METHOD == 'Orm_Functional_Locking_AllTests::main') {
AllTests::main();
}
\ No newline at end of file
<?php
namespace Doctrine\Tests\ORM\Locking;
use Doctrine\ORM\Locking;
namespace Doctrine\Tests\ORM\Functional\Locking;
use Doctrine\Tests\Mocks\MetadataDriverMock;
use Doctrine\Tests\Mocks\DatabasePlatformMock;
......@@ -14,7 +12,7 @@ use Doctrine\Common\EventManager;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\Tests\TestUtil;
require_once __DIR__ . '/../../TestInit.php';
require_once __DIR__ . '/../../../TestInit.php';
class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
{
......@@ -24,9 +22,9 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
try {
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Locking\OptimisticJoinedParent'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Locking\OptimisticJoinedChild'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Locking\OptimisticStandard')
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild'),
$this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard')
));
} catch (\Exception $e) {
// Swallow all exceptions. We do not test the schema tool here.
......@@ -50,7 +48,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
*/
public function testJoinedChildFailureThrowsException()
{
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Locking\OptimisticJoinedChild t WHERE t.name = :name');
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild t WHERE t.name = :name');
$q->setParameter('name', 'child');
$test = $q->getSingleResult();
......@@ -79,7 +77,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
*/
public function testJoinedParentFailureThrowsException()
{
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Locking\OptimisticJoinedParent t WHERE t.name = :name');
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedParent t WHERE t.name = :name');
$q->setParameter('name', 'parent');
$test = $q->getSingleResult();
......@@ -108,7 +106,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
*/
public function testStandardFailureThrowsException()
{
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Locking\OptimisticStandard t WHERE t.name = :name');
$q = $this->_em->createQuery('SELECT t FROM Doctrine\Tests\ORM\Functional\Locking\OptimisticStandard t WHERE t.name = :name');
$q->setParameter('name', 'test');
$test = $q->getSingleResult();
......@@ -129,7 +127,7 @@ class OptimisticTest extends \Doctrine\Tests\OrmFunctionalTestCase
* @DiscriminatorValue("parent")
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="discr", type="string")
* @SubClasses({"Doctrine\Tests\ORM\Locking\OptimisticJoinedChild"})
* @SubClasses({"Doctrine\Tests\ORM\Functional\Locking\OptimisticJoinedChild"})
*/
class OptimisticJoinedParent
{
......
......@@ -32,6 +32,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
$this->product->addFeature($this->firstFeature);
$this->product->addFeature($this->secondFeature);
$this->_em->save($this->product);
$this->_em->flush();
$this->assertFeatureForeignKeyIs($this->product->getId(), $this->firstFeature);
$this->assertFeatureForeignKeyIs($this->product->getId(), $this->secondFeature);
......@@ -40,6 +41,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testSavesAnEmptyCollection()
{
$this->_em->save($this->product);
$this->_em->flush();
$this->assertEquals(0, count($this->product->getFeatures()));
}
......@@ -47,6 +49,7 @@ class OneToManyBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testDoesNotSaveAnInverseSideSet() {
$this->product->brokenAddFeature($this->firstFeature);
$this->_em->save($this->product);
$this->_em->flush();
$this->assertFeatureForeignKeyIs(null, $this->firstFeature);
}
......
......@@ -28,6 +28,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->customer->setCart($this->cart);
$this->_em->save($this->customer);
$this->_em->flush();
$this->assertCartForeignKeyIs($this->customer->getId());
}
......@@ -35,6 +36,7 @@ class OneToOneBidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctional
public function testDoesNotSaveAnInverseSideSet() {
$this->customer->brokenSetCart($this->cart);
$this->_em->save($this->customer);
$this->_em->flush();
$this->assertCartForeignKeyIs(null);
}
......
......@@ -31,6 +31,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->customer->setMentor($this->mentor);
$this->_em->save($this->customer);
$this->_em->flush();
$this->assertForeignKeyIs($this->mentor->getId());
}
......@@ -59,7 +60,7 @@ class OneToOneSelfReferentialAssociationTest extends \Doctrine\Tests\OrmFunction
$this->_em->flush();
$this->_em->clear();
$query = $this->_em->createQuery('select c, m from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c left join c.mentor m');
$query = $this->_em->createQuery('select c, m from Doctrine\Tests\Models\ECommerce\ECommerceCustomer c left join c.mentor m order by c.id asc');
$result = $query->getResultList();
$customer = $result[0];
......
......@@ -29,6 +29,7 @@ class OneToOneUnidirectionalAssociationTest extends \Doctrine\Tests\OrmFunctiona
public function testSavesAOneToOneAssociationWithCascadeSaveSet() {
$this->product->setShipping($this->shipping);
$this->_em->save($this->product);
$this->_em->flush();
$this->assertForeignKeyIs($this->shipping->getId());
}
......
......@@ -77,15 +77,15 @@ class OrmFunctionalTestCase extends OrmTestCase
$conn->exec('DELETE FROM cms_users');
}
if (isset($this->_usedModelSets['ecommerce'])) {
$conn->exec('DELETE FROM ecommerce_carts_products');
$conn->exec('DELETE FROM ecommerce_products_categories');
$conn->exec('DELETE FROM ecommerce_products_related');
$conn->exec('DELETE FROM ecommerce_carts');
$conn->exec('DELETE FROM ecommerce_customers');
$conn->exec('DELETE FROM ecommerce_features');
$conn->exec('DELETE FROM ecommerce_products');
$conn->exec('DELETE FROM ecommerce_carts_products');
$conn->exec('DELETE FROM ecommerce_shippings');
$conn->exec('DELETE FROM ecommerce_features');
$conn->exec('DELETE FROM ecommerce_categories');
$conn->exec('DELETE FROM ecommerce_products_categories');
$conn->exec('DELETE FROM ecommerce_products_related');
}
if (isset($this->_usedModelSets['company'])) {
$conn->exec('DELETE FROM company_persons_friends');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment