MappedSuperclassTest.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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->assertType('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent());
  32. $this->assertEquals($directory->getId(), $cleanFile->getParent()->getId());
  33. $this->assertType('Doctrine\Tests\Models\DirectoryTree\Directory', $cleanFile->getParent()->getParent());
  34. $this->assertEquals($root->getId(), $cleanFile->getParent()->getParent()->getId());
  35. }
  36. }