diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 9cc3b8f5c..1a60f7eb7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -18,4 +18,73 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); } + + public function testJoinTablesWithMappedSuperclassForYamlDriver() + { + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/yaml/')); + $qb = $em->createQueryBuilder(); + + $qb->select('f') + ->from('Doctrine\Tests\ORM\Mapping\Page', 'f') + ->join('f.parentDirectory', 'd') + ->where( + $qb->expr()->andx( + $qb->expr()->eq('d.url', ':url'), + $qb->expr()->eq('f.extension', ':extension') + ) + ) + ->setParameter('url', "test") + ->setParameter('filename', "filename") + ->setParameter('extension', "extension"); + + // Is there a way to generalize this more? (Instead of a2_., check if the table prefix in the ON clause is set within a FROM or JOIN clause..) + $this->assertTrue(strpos($qb->getQuery()->getSql(), 'a2_.') === false); + } + +} + +class Directory extends AbstractContentItem +{ + + protected $subDirectories; + /** + * This is a collection of files that are contained in this Directory. Files, for example, could be Pages, but even other files + * like media files (css, images etc) are possible. + * + * @var \Doctrine\Common\Collections\Collection + * @access protected + */ + protected $containedFiles; + /** + * @var string + */ + protected $url; +} + +class Page extends AbstractContentItem +{ + + protected $extension = "html"; + +} + +abstract class AbstractContentItem +{ + + /** + * Doctrine2 entity id + * @var integer + */ + private $id; + /** + * The parent directory + * @var Directory + */ + protected $parentDirectory; + /** + * Filename (without extension) or directory name + * @var string + */ + protected $name; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.AbstractContentItem.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.AbstractContentItem.dcm.yml new file mode 100644 index 000000000..419eb0449 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.AbstractContentItem.dcm.yml @@ -0,0 +1,17 @@ +Doctrine\Tests\ORM\Mapping\AbstractContentItem: + type: mappedSuperclass + table: abstract_item + id: + id: + type: integer + unsigned: true + generator: + strategy: AUTO + fields: + # FilesystemIdentifier + manyToOne: + parentDirectory: + targetEntity: Doctrine\Tests\ORM\Mapping\Directory + joinColumn: + name: parent_directory_id + referencedColumnName: id diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Directory.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Directory.dcm.yml new file mode 100644 index 000000000..129ae6b28 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Directory.dcm.yml @@ -0,0 +1,17 @@ +Doctrine\Tests\ORM\Mapping\Directory: + type: entity + table: core_content_directories + fields: + url: + type: string + length: 255 + oneToMany: + subDirectories: + targetEntity: Doctrine\Tests\ORM\Mapping\Directory + mappedBy: parentDirectory + cascade: + [ all ] + containedFiles: + targetEntity: Doctrine\Tests\ORM\Mapping\Page + mappedBy: parentDirectory + cascade: [ remove ] diff --git a/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Page.dcm.yml b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Page.dcm.yml new file mode 100644 index 000000000..a3b0fb836 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/yaml/Doctrine.Tests.ORM.Mapping.Page.dcm.yml @@ -0,0 +1,7 @@ +Doctrine\Tests\ORM\Mapping\Page: + type: entity + table: core_content_pages + fields: + extension: + type: string + length: 10