From 602c3be3fc30bfa7f8839eb13aa94fd236d40f01 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sat, 14 Dec 2013 19:57:53 +0100 Subject: [PATCH] Cleaned up tests for DDC-2775 --- .../Tests/Models/DDC2775/Authorization.php | 21 +++---------------- tests/Doctrine/Tests/Models/DDC2775/Role.php | 21 +++---------------- tests/Doctrine/Tests/Models/DDC2775/User.php | 11 +++------- .../ORM/Functional/Ticket/DDC2775Test.php | 5 +++-- 4 files changed, 12 insertions(+), 46 deletions(-) diff --git a/tests/Doctrine/Tests/Models/DDC2775/Authorization.php b/tests/Doctrine/Tests/Models/DDC2775/Authorization.php index 25d104123..caeae2b24 100644 --- a/tests/Doctrine/Tests/Models/DDC2775/Authorization.php +++ b/tests/Doctrine/Tests/Models/DDC2775/Authorization.php @@ -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; } diff --git a/tests/Doctrine/Tests/Models/DDC2775/Role.php b/tests/Doctrine/Tests/Models/DDC2775/Role.php index 7812b2e89..4ef0ac462 100644 --- a/tests/Doctrine/Tests/Models/DDC2775/Role.php +++ b/tests/Doctrine/Tests/Models/DDC2775/Role.php @@ -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; } } diff --git a/tests/Doctrine/Tests/Models/DDC2775/User.php b/tests/Doctrine/Tests/Models/DDC2775/User.php index 67b46f25e..d42685679 100644 --- a/tests/Doctrine/Tests/Models/DDC2775/User.php +++ b/tests/Doctrine/Tests/Models/DDC2775/User.php @@ -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; } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php index f8259f7c8..6e2a61d19 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2775Test.php @@ -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 */ -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();