2010-02-02 00:48:27 +03:00
|
|
|
<?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()
|
|
|
|
{
|
2010-08-23 10:21:41 +04:00
|
|
|
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.');
|
|
|
|
}
|
|
|
|
|
2010-02-02 00:48:27 +03:00
|
|
|
return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml');
|
|
|
|
}
|
2010-09-17 00:27:04 +04:00
|
|
|
|
|
|
|
public function testJoinTablesWithMappedSuperclassForYamlDriver()
|
|
|
|
{
|
2010-07-06 22:19:43 +04:00
|
|
|
$em = $this->_getTestEntityManager();
|
2010-09-17 00:27:04 +04:00
|
|
|
$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-09-17 00:27:04 +04:00
|
|
|
|
2010-07-06 22:19:43 +04:00
|
|
|
}
|
|
|
|
|
2010-09-17 00:27:04 +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;
|
|
|
|
}
|
|
|
|
|
2010-09-17 00:27:04 +04:00
|
|
|
class Page extends AbstractContentItem
|
|
|
|
{
|
|
|
|
|
2010-07-06 22:19:43 +04:00
|
|
|
protected $extension = "html";
|
2010-09-17 00:27:04 +04:00
|
|
|
|
2010-07-06 22:19:43 +04:00
|
|
|
}
|
|
|
|
|
2010-09-17 00:27:04 +04:00
|
|
|
abstract class AbstractContentItem
|
|
|
|
{
|
|
|
|
|
2010-07-06 22:19:43 +04:00
|
|
|
/**
|
|
|
|
* Doctrine2 entity id
|
|
|
|
* @var integer
|
|
|
|
*/
|
2010-09-17 00:27:04 +04:00
|
|
|
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;
|
2010-08-23 10:21:41 +04:00
|
|
|
}
|