1
0
mirror of synced 2024-12-14 23:26:04 +03:00

Merge pull request #219 from FabioBatSilva/DDC-1468

Fixed DDC-1468
This commit is contained in:
Guilherme Blanco 2011-12-18 19:20:33 -08:00
commit f6d9344d89
6 changed files with 60 additions and 0 deletions

View File

@ -118,6 +118,9 @@ abstract class AbstractFileDriver implements Driver
{ {
$result = $this->_loadMappingFile($this->_findMappingFile($className)); $result = $this->_loadMappingFile($this->_findMappingFile($className));
if(!isset($result[$className])){
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->_fileExtension);
}
return $result[$className]; return $result[$className];
} }

View File

@ -68,6 +68,11 @@ class MappingException extends \Doctrine\ORM\ORMException
return new self("No mapping file found named '$fileName' for class '$entityName'."); return new self("No mapping file found named '$fileName' for class '$entityName'.");
} }
public static function invalidMappingFile($entityName, $fileName)
{
return new self("Invalid mapping file '$fileName' for class '$entityName'.");
}
public static function mappingNotFound($className, $fieldName) public static function mappingNotFound($className, $fieldName)
{ {
return new self("No mapping found for field '$fieldName' on class '$className'."); return new self("No mapping found for field '$fieldName' on class '$className'.");

View File

@ -51,6 +51,17 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
$this->assertTrue($class->associationMappings['article']['id']); $this->assertTrue($class->associationMappings['article']['id']);
} }
/**
* @group DDC-1468
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
*/
public function testInvalidMappingFileException()
{
$this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel');
}
/** /**
* @param string $xmlMappingFile * @param string $xmlMappingFile
* @dataProvider dataValidSchema * @dataProvider dataValidSchema

View File

@ -43,4 +43,15 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
$this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']); $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']);
} }
/**
* @group DDC-1468
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @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');
}
} }

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="\stdClass">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="array" column="array" type="array"/>
<field name="object" column="object" type="object"/>
</entity>
</doctrine-mapping>

View File

@ -0,0 +1,13 @@
\stdClass:
type: entity
id:
id:
type: integer
unsigned: true
generator:
strategy: AUTO
fields:
array:
type: array
object:
type: object