1
0
mirror of synced 2024-12-14 15:16:04 +03:00
doctrine2/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php

89 lines
2.4 KiB
PHP
Raw Normal View History

<?php
namespace Doctrine\Tests\ORM\Mapping;
use Doctrine\ORM\Mapping\ClassMetadata,
Doctrine\ORM\Mapping\Driver\XmlDriver,
Doctrine\ORM\Mapping\Driver\YamlDriver;
require_once __DIR__ . '/../../TestInit.php';
class YamlMappingDriverTest extends AbstractMappingDriverTest
{
protected function _loadDriver()
{
if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
2010-04-07 22:35:33 +04:00
$this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
}
return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml');
}
public function testJoinTablesWithMappedSuperclassForYamlDriver()
{
2010-07-06 22:19:43 +04:00
$em = $this->_getTestEntityManager();
$em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/yaml/'));
2010-09-20 21:23:41 +04:00
var_dump($em->getClassMetadata('Doctrine\Tests\ORM\Mapping\Page'));
var_dump($em->getClassMetadata('Doctrine\Tests\ORM\Mapping\Directory'));
$dql = "SELECT f FROM Doctrine\Tests\ORM\Mapping\Page f JOIN f.parentDirectory d " .
"WHERE (d.url = :url) AND (f.extension = :extension)";
$query = $em->createQuery($dql)
->setParameter('url', "test")
->setParameter('extension', "extension");
var_dump($query->getSql());
2010-07-06 22:19:43 +04:00
// 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..)
2010-09-20 21:23:41 +04:00
$this->assertTrue(strpos($query->getSql(), 'a2_.') === false);
2010-07-06 22:19:43 +04:00
}
2010-07-06 22:19:43 +04:00
}
class Directory extends AbstractContentItem
{
2010-07-06 22:19:43 +04:00
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
{
2010-07-06 22:19:43 +04:00
protected $extension = "html";
2010-07-06 22:19:43 +04:00
}
abstract class AbstractContentItem
{
2010-07-06 22:19:43 +04:00
/**
* Doctrine2 entity id
* @var integer
*/
private $id;
2010-07-06 22:19:43 +04:00
/**
* The parent directory
* @var Directory
*/
protected $parentDirectory;
/**
* Filename (without extension) or directory name
* @var string
*/
protected $name;
}