MappedSuperclassTest.php 1.5KB

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