Skip to content

Commit

Permalink
Moving exception throwing for invalid file mappings to Doctrine\Commo…
Browse files Browse the repository at this point in the history
…n\Persistence\Mapping\Driver\FileDriver
  • Loading branch information
Ocramius committed Jul 4, 2012
1 parent 03fb734 commit ccace8c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 24 deletions.
16 changes: 0 additions & 16 deletions lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
Expand Up @@ -41,20 +41,4 @@
*/
abstract class AbstractFileDriver extends FileDriver implements Driver
{
/**
* Get the element of schema meta data for the class from the mapping file.
* This will lazily load the mapping file if it is not loaded yet
*
* @return array $element The element of schema meta data
* @throws MappingException
* @todo move behavior to FileDriver
*/
public function getElement($className)
{
$result = parent::getElement($className);
if($result === null) {
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension());
}
return $result;
}
}
7 changes: 1 addition & 6 deletions lib/Doctrine/ORM/Mapping/MappingException.php
Expand Up @@ -78,11 +78,6 @@ 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'.");
}

/**
* Exception for invalid property name override.
*
Expand Down Expand Up @@ -144,7 +139,7 @@ public static function missingResultSetMappingFieldName($entity, $resultName)
{
return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a field name.');
}

public static function nameIsMandatoryForSqlResultSetMapping($className)
{
return new self("Result set mapping name on entity class '$className' is not defined.");
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php
Expand Up @@ -55,7 +55,7 @@ public function testIdentifierWithAssociationKey()
/**
* @group DDC-1468
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
*/
public function testInvalidMappingFileException()
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php
Expand Up @@ -46,7 +46,7 @@ public function testJoinTablesWithMappedSuperclassForYamlDriver()
/**
* @group DDC-1468
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
*/
public function testInvalidMappingFileException()
Expand Down

0 comments on commit ccace8c

Please sign in to comment.