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
|
|
|
|
2010-09-22 01:14:45 +04:00
|
|
|
/**
|
|
|
|
* @group DDC-671
|
|
|
|
*
|
|
|
|
* Entities for this test are in AbstractMappingDriverTest
|
|
|
|
*/
|
2010-09-17 00:27:04 +04:00
|
|
|
public function testJoinTablesWithMappedSuperclassForYamlDriver()
|
|
|
|
{
|
2010-09-22 01:53:26 +04:00
|
|
|
$yamlDriver = $this->_loadDriver();
|
2012-01-17 17:31:27 +04:00
|
|
|
$yamlDriver->getLocator()->addPaths(array(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'));
|
2010-09-20 21:23:41 +04:00
|
|
|
|
2010-09-22 01:53:26 +04:00
|
|
|
$em = $this->_getTestEntityManager();
|
|
|
|
$em->getConfiguration()->setMetadataDriverImpl($yamlDriver);
|
2010-11-27 22:53:26 +03:00
|
|
|
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
|
|
|
|
$factory->setEntityManager($em);
|
2010-09-20 21:23:41 +04:00
|
|
|
|
2010-09-22 01:53:26 +04:00
|
|
|
$classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File');
|
|
|
|
$classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File');
|
|
|
|
$this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']);
|
2010-09-20 21:23:41 +04:00
|
|
|
|
2010-09-22 01:53:26 +04:00
|
|
|
$classDirectory = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\Directory');
|
|
|
|
$classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory');
|
|
|
|
$this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']);
|
2010-07-06 22:19:43 +04:00
|
|
|
}
|
2010-09-17 00:27:04 +04:00
|
|
|
|
2011-12-15 23:12:01 +04:00
|
|
|
/**
|
|
|
|
* @group DDC-1468
|
|
|
|
*
|
2012-01-17 18:39:52 +04:00
|
|
|
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
|
2011-12-15 23:12:01 +04:00
|
|
|
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
|
|
|
|
*/
|
|
|
|
public function testInvalidMappingFileException()
|
|
|
|
{
|
|
|
|
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel');
|
|
|
|
}
|
|
|
|
|
2012-10-20 07:28:38 +04:00
|
|
|
/**
|
|
|
|
* @group DDC-2069
|
|
|
|
*/
|
|
|
|
public function testSpacesShouldBeIgnoredWhenUseExplode()
|
|
|
|
{
|
|
|
|
$metadata = $this->createClassMetadata(__NAMESPACE__.'\DDC2069Entity');
|
|
|
|
$unique = $metadata->table['uniqueConstraints'][0]['columns'];
|
|
|
|
$indexes = $metadata->table['indexes'][0]['columns'];
|
|
|
|
|
|
|
|
$nameField = $metadata->fieldMappings['name'];
|
|
|
|
$valueField = $metadata->fieldMappings['value'];
|
|
|
|
|
|
|
|
$this->assertEquals('name', $unique[0]);
|
|
|
|
$this->assertEquals('value', $unique[1]);
|
|
|
|
|
|
|
|
$this->assertEquals('value', $indexes[0]);
|
|
|
|
$this->assertEquals('name', $indexes[1]);
|
|
|
|
|
|
|
|
$this->assertEquals(255, $nameField['length']);
|
|
|
|
$this->assertEquals(255, $valueField['length']);
|
|
|
|
}
|
|
|
|
|
2010-07-06 22:19:43 +04:00
|
|
|
}
|
2012-10-20 07:28:38 +04:00
|
|
|
|
|
|
|
class DDC2069Entity
|
|
|
|
{
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
public $name;
|
|
|
|
|
|
|
|
public $value;
|
|
|
|
}
|