Permalink
Browse files

test invalid class/method

  • Loading branch information...
1 parent 7e54ae3 commit 917aa70c9745a0f946ae34ebd870108fe3f0ffa4 @FabioBatSilva committed with fabio.silva Aug 4, 2012
View
2 lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
@@ -2505,7 +2505,7 @@ public function addEntityListener($eventName, $class, $method)
throw MappingException::entityListenerClassNotFound($class, $this->name);
}
- if ( !method_exists($class, $method)) {
+ if ( ! method_exists($class, $method)) {
throw MappingException::entityListenerMethodNotFound($class, $method, $this->name);
}
View
28 tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
@@ -997,6 +997,34 @@ public function testInvalidOverrideAttributeFieldTypeException()
$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

0 comments on commit 917aa70

Please sign in to comment.