Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed DDC-1468 #219

Merged
merged 1 commit into from
Dec 19, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public function getElement($className)
{
$result = $this->_loadMappingFile($this->_findMappingFile($className));

if(!isset($result[$className])){
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->_fileExtension);
}
return $result[$className];
}

Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/ORM/Mapping/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public static function mappingFileNotFound($entityName, $fileName)
{
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)
{
Expand Down
11 changes: 11 additions & 0 deletions tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ public function testIdentifierWithAssociationKey()
$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
* @dataProvider dataValidSchema
Expand Down
11 changes: 11 additions & 0 deletions tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver()
$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');
}

}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\stdClass:
type: entity
id:
id:
type: integer
unsigned: true
generator:
strategy: AUTO
fields:
array:
type: array
object:
type: object