Merge branch 'DDC-996'
This commit is contained in:
commit
482ff2d009
@ -658,8 +658,8 @@ class ClassMetadataInfo
|
|||||||
protected function _validateAndCompleteFieldMapping(array &$mapping)
|
protected function _validateAndCompleteFieldMapping(array &$mapping)
|
||||||
{
|
{
|
||||||
// Check mandatory fields
|
// Check mandatory fields
|
||||||
if ( ! isset($mapping['fieldName'])) {
|
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
|
||||||
throw MappingException::missingFieldName($this->name, $mapping);
|
throw MappingException::missingFieldName($this->name);
|
||||||
}
|
}
|
||||||
if ( ! isset($mapping['type'])) {
|
if ( ! isset($mapping['type'])) {
|
||||||
// Default to string
|
// Default to string
|
||||||
@ -749,8 +749,8 @@ class ClassMetadataInfo
|
|||||||
|
|
||||||
// Mandatory attributes for both sides
|
// Mandatory attributes for both sides
|
||||||
// Mandatory: fieldName, targetEntity
|
// Mandatory: fieldName, targetEntity
|
||||||
if ( ! isset($mapping['fieldName'])) {
|
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
|
||||||
throw MappingException::missingFieldName();
|
throw MappingException::missingFieldName($this->name);
|
||||||
}
|
}
|
||||||
if ( ! isset($mapping['targetEntity'])) {
|
if ( ! isset($mapping['targetEntity'])) {
|
||||||
throw MappingException::missingTargetEntity($mapping['fieldName']);
|
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.");
|
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)
|
public static function missingTargetEntity($fieldName)
|
||||||
|
@ -379,4 +379,15 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
'joinColumns' => array(),
|
'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