Skip to content

Commit

Permalink
doctrine#1169 DDC-3343 - minor refactoring: constant over string refe…
Browse files Browse the repository at this point in the history
…rence
  • Loading branch information
Ocramius committed Jan 24, 2015
1 parent ff01688 commit 24ebfb6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3343Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class DDC3343Test extends \Doctrine\Tests\OrmFunctionalTestCase
public function testEntityNotDeletedWhenRemovedFromExtraLazyAssociation()
{
$this->_schemaTool->createSchema(array(
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3343User'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3343Group'),
$this->_em->getClassMetadata(DDC3343User::CLASSNAME),
$this->_em->getClassMetadata(DDC3343Group::CLASSNAME),
));

// Save a group and an associated user (in an extra lazy association)
Expand All @@ -34,16 +34,19 @@ public function testEntityNotDeletedWhenRemovedFromExtraLazyAssociation()
// Fetch the group and the user again and remove the user from the collection.
$this->_em->clear();

$group = $this->_em->find(__NAMESPACE__ . '\DDC3343Group', $group->id);
$user = $this->_em->find(__NAMESPACE__ . '\DDC3343User', $user->id);
$group = $this->_em->find(DDC3343Group::CLASSNAME, $group->id);
$user = $this->_em->find(DDC3343User::CLASSNAME, $user->id);

$group->users->removeElement($user);

// Even though the collection is extra lazy, the user should not have been deleted.
$this->_em->clear();

$user = $this->_em->find(__NAMESPACE__ . '\DDC3343User', $user->id);
$this->assertInstanceOf(__NAMESPACE__ . '\DDC3343User', $user);
/* @var $user DDC3343User */
$user = $this->_em->find(DDC3343User::CLASSNAME, $user->id);
$this->assertInstanceOf(DDC3343User::CLASSNAME, $user);

$this->assertNull($user->group);
}
}

Expand All @@ -52,6 +55,8 @@ public function testEntityNotDeletedWhenRemovedFromExtraLazyAssociation()
*/
class DDC3343User
{
const CLASSNAME = __CLASS__;

/**
* @Id
* @GeneratedValue
Expand All @@ -62,14 +67,16 @@ class DDC3343User
/**
* @ManyToOne(targetEntity="DDC3343Group", inversedBy="users")
*/
protected $group;
public $group;
}

/**
* @Entity
*/
class DDC3343Group
{
const CLASSNAME = __CLASS__;

/**
* @Id
* @GeneratedValue
Expand Down

0 comments on commit 24ebfb6

Please sign in to comment.