Merge branch 'DDC-996'
This commit is contained in:
commit
482ff2d009
@ -658,8 +658,8 @@ class ClassMetadataInfo
|
||||
protected function _validateAndCompleteFieldMapping(array &$mapping)
|
||||
{
|
||||
// Check mandatory fields
|
||||
if ( ! isset($mapping['fieldName'])) {
|
||||
throw MappingException::missingFieldName($this->name, $mapping);
|
||||
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
|
||||
throw MappingException::missingFieldName($this->name);
|
||||
}
|
||||
if ( ! isset($mapping['type'])) {
|
||||
// Default to string
|
||||
@ -749,8 +749,8 @@ class ClassMetadataInfo
|
||||
|
||||
// Mandatory attributes for both sides
|
||||
// Mandatory: fieldName, targetEntity
|
||||
if ( ! isset($mapping['fieldName'])) {
|
||||
throw MappingException::missingFieldName();
|
||||
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
|
||||
throw MappingException::missingFieldName($this->name);
|
||||
}
|
||||
if ( ! isset($mapping['targetEntity'])) {
|
||||
throw MappingException::missingTargetEntity($mapping['fieldName']);
|
||||
|
@ -48,9 +48,9 @@ class MappingException extends \Doctrine\ORM\ORMException
|
||||
return new self("Id generators can't be used with a composite id.");
|
||||
}
|
||||
|
||||
public static function missingFieldName()
|
||||
public static function missingFieldName($entity)
|
||||
{
|
||||
return new self("The association mapping misses the 'fieldName' attribute.");
|
||||
return new self("The field or association mapping misses the 'fieldName' attribute in entity '$entity'.");
|
||||
}
|
||||
|
||||
public static function missingTargetEntity($fieldName)
|
||||
|
@ -379,4 +379,15 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
||||
'joinColumns' => array(),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-996
|
||||
*/
|
||||
public function testEmptyFieldNameThrowsException()
|
||||
{
|
||||
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException',
|
||||
"The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'.");
|
||||
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
|
||||
$cm->mapField(array('fieldName' => ''));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user