1
0
mirror of synced 2024-12-13 22:56:04 +03:00

test invalid class/method

This commit is contained in:
Fabio B. Silva 2012-08-04 18:02:32 -03:00 committed by fabio.silva
parent 7e54ae3702
commit 917aa70c97
2 changed files with 29 additions and 1 deletions

View File

@ -2505,7 +2505,7 @@ class ClassMetadataInfo implements ClassMetadata
throw MappingException::entityListenerClassNotFound($class, $this->name);
}
if ( !method_exists($class, $method)) {
if ( ! method_exists($class, $method)) {
throw MappingException::entityListenerMethodNotFound($class, $method, $this->name);
}

View File

@ -997,6 +997,34 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$cm->setAttributeOverride('name', array('type'=>'date'));
}
/**
* @group DDC-1955
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedExceptionMessage Entity Listener "\InvalidClassName" declared on "Doctrine\Tests\Models\CMS\CmsUser" not found.
*/
public function testInvalidEntityListenerClassException()
{
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm->addEntityListener(Events::postLoad, '\InvalidClassName', 'postLoadHandler');
}
/**
* @group DDC-1955
*
* @expectedException Doctrine\ORM\Mapping\MappingException
* @expectedExceptionMessage Entity Listener "\Doctrine\Tests\Models\Company\ContractSubscriber" declared on "Doctrine\Tests\Models\CMS\CmsUser" has no method "invalidMethod".
*/
public function testInvalidEntityListenerMethodException()
{
$cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser');
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService);
$cm->addEntityListener(Events::postLoad, '\Doctrine\Tests\Models\Company\ContractSubscriber', 'invalidMethod');
}
}
class MyNamespacedNamingStrategy extends \Doctrine\ORM\Mapping\DefaultNamingStrategy