Cleaned up tests for DDC-2775
This commit is contained in:
parent
1899bcf000
commit
602c3be3fc
@ -11,30 +11,15 @@ class Authorization
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
private $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="authorizations")
|
||||
*/
|
||||
private $user;
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Role", inversedBy="authorizations")
|
||||
*/
|
||||
private $role;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function setRole(Role $role)
|
||||
{
|
||||
$this->role = $role;
|
||||
}
|
||||
public $role;
|
||||
}
|
||||
|
@ -14,36 +14,21 @@ abstract class Role
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue
|
||||
*/
|
||||
private $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="User", inversedBy="roles")
|
||||
*/
|
||||
private $user;
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Authorization", mappedBy="role", cascade={"all"}, orphanRemoval=true)
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->setRole($this);
|
||||
$authorization->role = $this;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class User
|
||||
* @Id @Column(type="integer")
|
||||
* @GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
private $id;
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @OneToMany(targetEntity="Role", mappedBy="user", cascade={"all"}, orphanRemoval=true)
|
||||
@ -23,20 +23,15 @@ class User
|
||||
*/
|
||||
public $authorizations;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function addRole(Role $role)
|
||||
{
|
||||
$this->roles[] = $role;
|
||||
$role->setUser($this);
|
||||
$role->user = $this;
|
||||
}
|
||||
|
||||
public function addAuthorization(Authorization $authorization)
|
||||
{
|
||||
$this->authorizations[] = $authorization;
|
||||
$authorization->setUser($this);
|
||||
$authorization->user = $this;
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,14 @@ 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;
|
||||
|
||||
/**
|
||||
* Functional tests for cascade remove with class table inheritance.
|
||||
*
|
||||
* @author Matthieu Napoli <matthieu@mnapoli.fr>
|
||||
*/
|
||||
class DDC2775Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
class DDC2775Test extends OrmFunctionalTestCase
|
||||
{
|
||||
protected function setUp() {
|
||||
$this->useModelSet('ddc2775');
|
||||
@ -38,7 +39,7 @@ class DDC2775Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
// Need to clear so that associations are lazy-loaded
|
||||
$this->_em->clear();
|
||||
|
||||
$user = $this->_em->find('Doctrine\Tests\Models\DDC2775\User', $user->getId());
|
||||
$user = $this->_em->find('Doctrine\Tests\Models\DDC2775\User', $user->id);
|
||||
|
||||
$this->_em->remove($user);
|
||||
$this->_em->flush();
|
||||
|
Loading…
Reference in New Issue
Block a user