Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / MappedSuperclassTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional;
4
5 require_once __DIR__ . '/../../TestInit.php';
6
7 /**
8  * MappedSuperclassTest
9  *
10  * @author robo
11  */
12 class MappedSuperclassTest extends \Doctrine\Tests\OrmFunctionalTestCase
13 {
14     protected function setUp() {
15         $this->useModelSet('directorytree');
16         parent::setUp();
17     }
18
19     public function testCRUD()
20     {
21         $root = new \Doctrine\Tests\Models\DirectoryTree\Directory();
22         $root->setName('Root');
23         $root->setPath('/root');
24
25         $directory = new \Doctrine\Tests\Models\DirectoryTree\Directory($root);
26         $directory->setName('TestA');
27         $directory->setPath('/root/dir');
28
29         $file = new \Doctrine\Tests\Models\DirectoryTree\File($directory);
30         $file->setName('test-b.html');
31
32         $this->_em->persist($root);
33         $this->_em->persist($directory);
34         $this->_em->persist($file);
35
36         $this->_em->flush();
37         $this->_em->clear();
38
39         $cleanFile = $this->_em->find(get_class($file), $file->getId());
40
41         $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent());
42         $this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $cleanFile->getParent());
43         $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId());
44         $this->assertInstanceOf('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent());
45         $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId());
46     }
47 }