Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC960Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6
7 require_once __DIR__ . '/../../../TestInit.php';
8
9 class DDC960Test extends \Doctrine\Tests\OrmFunctionalTestCase
10 {
11     protected function setUp()
12     {
13         parent::setUp();
14         try {
15             $this->_schemaTool->createSchema(array(
16                 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Root'),
17                 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC960Child')
18             ));
19         } catch(\Exception $e) {
20
21         }
22     }
23
24     /**
25      * @group DDC-960
26      */
27     public function testUpdateRootVersion()
28     {
29         $child = new DDC960Child('Test');
30         $this->_em->persist($child);
31         $this->_em->flush();
32
33         $child->setName("Test2");
34
35         $this->_em->flush();
36
37         $this->assertEquals(2, $child->getVersion());
38     }
39 }
40
41 /**
42  * @Entity
43  * @InheritanceType("JOINED")
44  * @DiscriminatorMap({
45  *  "root" = "DDC960Root",
46  *  "child" = "DDC960Child"
47  * })
48  */
49 class DDC960Root
50 {
51     /**
52      * @Id @GeneratedValue @Column(type="integer")
53      */
54     private $id;
55
56     /**
57      * @Column(type="integer") @Version
58      */
59     private $version;
60
61     public function getId()
62     {
63         return $this->id;
64     }
65
66     public function getVersion()
67     {
68         return $this->version;
69     }
70 }
71
72 /**
73  * @Entity
74  */
75 class DDC960Child extends DDC960Root
76 {
77     /**
78      * @column(type="string")
79      * @var string
80      */
81     private $name;
82
83     public function __construct($name)
84     {
85         $this->name = $name;
86     }
87
88     public function setName($name)
89     {
90         $this->name = $name;
91     }
92 }