Inlined the model for the DCC2775 test case inside the test class
This commit is contained in:
parent
602c3be3fc
commit
c9791fe97f
@ -2232,8 +2232,6 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
$entitiesToCascade = array();
|
||||
|
||||
// We need to load all related entities beforehand so that lazy collection loading doesn't
|
||||
// reload entities after they have been removed (bug DDC-2775)
|
||||
foreach ($associationMappings as $assoc) {
|
||||
if ($entity instanceof Proxy && !$entity->__isInitialized__) {
|
||||
$entity->__load();
|
||||
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC2775;
|
||||
|
||||
/** @Entity */
|
||||
class AdminRole extends Role
|
||||
{
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC2775;
|
||||
|
||||
/**
|
||||
* @Entity @Table(name="authorizations")
|
||||
*/
|
||||
class Authorization
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="authorizations")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Role", inversedBy="authorizations")
|
||||
*/
|
||||
public $role;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC2775;
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("JOINED")
|
||||
* @DiscriminatorColumn(name="role_type", type="string")
|
||||
* @DiscriminatorMap({"admin"="AdminRole"})
|
||||
*/
|
||||
abstract class Role
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="roles")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Authorization", mappedBy="role", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->role = $this;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\Models\DDC2775;
|
||||
|
||||
/**
|
||||
* @Entity @Table(name="users")
|
||||
*/
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $roles;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Authorization", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function addRole(Role $role)
|
||||
{
|
||||
$this->roles[] = $role;
|
||||
$role->user = $this;
|
||||
}
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->user = $this;
|
||||
}
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Tests\Models\DDC2775\AdminRole;
|
||||
use Doctrine\Tests\Models\DDC2775\Authorization;
|
||||
use Doctrine\Tests\Models\DDC2775\User;
|
||||
use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
|
||||
/**
|
||||
@ -14,9 +11,16 @@ use Doctrine\Tests\OrmFunctionalTestCase;
|
||||
*/
|
||||
class DDC2775Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() {
|
||||
$this->useModelSet('ddc2775');
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setUpEntitySchema(array(
|
||||
'Doctrine\Tests\ORM\Functional\Ticket\User',
|
||||
'Doctrine\Tests\ORM\Functional\Ticket\Role',
|
||||
'Doctrine\Tests\ORM\Functional\Ticket\AdminRole',
|
||||
'Doctrine\Tests\ORM\Functional\Ticket\Authorization',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,7 +43,7 @@ class DDC2775Test extends OrmFunctionalTestCase
|
||||
// Need to clear so that associations are lazy-loaded
|
||||
$this->_em->clear();
|
||||
|
||||
$user = $this->_em->find('Doctrine\Tests\Models\DDC2775\User', $user->id);
|
||||
$user = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\User', $user->id);
|
||||
|
||||
$this->_em->remove($user);
|
||||
$this->_em->flush();
|
||||
@ -48,3 +52,95 @@ class DDC2775Test extends OrmFunctionalTestCase
|
||||
$this->_em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity
|
||||
* @InheritanceType("JOINED")
|
||||
* @DiscriminatorColumn(name="role_type", type="string")
|
||||
* @DiscriminatorMap({"admin"="AdminRole"})
|
||||
*/
|
||||
abstract class Role
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="roles")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Authorization", mappedBy="role", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->role = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/** @Entity */
|
||||
class AdminRole extends Role
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity @Table(name="authorizations")
|
||||
*/
|
||||
class Authorization
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="authorizations")
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Role", inversedBy="authorizations")
|
||||
*/
|
||||
public $role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Entity @Table(name="users")
|
||||
*/
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $roles;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Authorization", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function addRole(Role $role)
|
||||
{
|
||||
$this->roles[] = $role;
|
||||
$role->user = $this;
|
||||
}
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->user = $this;
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +162,6 @@ abstract class OrmFunctionalTestCase extends OrmTestCase
|
||||
'Doctrine\Tests\Models\Taxi\Car',
|
||||
'Doctrine\Tests\Models\Taxi\Driver',
|
||||
),
|
||||
'ddc2775' => array(
|
||||
'Doctrine\Tests\Models\DDC2775\User',
|
||||
'Doctrine\Tests\Models\DDC2775\Role',
|
||||
'Doctrine\Tests\Models\DDC2775\AdminRole',
|
||||
'Doctrine\Tests\Models\DDC2775\Authorization',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user