From 93b2cb0a5834b44d49068c2b4194ee55b52eabc6 Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 12 Sep 2008 09:37:05 +0000 Subject: [PATCH] moved entity/entitymanager exceptions --- lib/Doctrine/Entity.php | 2 +- lib/Doctrine/Entity/Exception.php | 65 ------------------------ lib/Doctrine/EntityManager.php | 2 +- lib/Doctrine/EntityManager/Exception.php | 60 ---------------------- tests/Orm/Component/AccessTest.php | 4 +- tests/Orm/EntityManagerTest.php | 2 +- 6 files changed, 5 insertions(+), 130 deletions(-) delete mode 100644 lib/Doctrine/Entity/Exception.php delete mode 100644 lib/Doctrine/EntityManager/Exception.php diff --git a/lib/Doctrine/Entity.php b/lib/Doctrine/Entity.php index c7650df4f..9053be4fb 100644 --- a/lib/Doctrine/Entity.php +++ b/lib/Doctrine/Entity.php @@ -453,7 +453,7 @@ abstract class Doctrine_Entity implements ArrayAccess, Serializable } } } else { - throw Doctrine_Entity_Exception::invalidField($fieldName); + throw Doctrine_ORM_Exceptions_EntityException::invalidField($fieldName); } } diff --git a/lib/Doctrine/Entity/Exception.php b/lib/Doctrine/Entity/Exception.php deleted file mode 100644 index 8798a5a6b..000000000 --- a/lib/Doctrine/Entity/Exception.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -#namespace Doctrine::ORM; - -/** - * Doctrine_Entity_Exception - * - * @package Doctrine - * @subpackage Entity - * @author Konsta Vesterinen - * @author Roman Borschel - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 2.0 - * @version $Revision$ - */ -class Doctrine_Entity_Exception extends Doctrine_Exception -{ - public static function unknownField($field) - { - return new self("Undefined field: '$field'."); - } - - public static function invalidValueForOneToManyReference() - { - return new self("Invalid value. The value of a reference in a OneToMany " - . "association must be a Collection."); - } - - public static function invalidValueForOneToOneReference() - { - return new self("Invalid value. The value of a reference in a OneToOne " - . "association must be an Entity."); - } - - public static function invalidValueForManyToManyReference() - { - return new self("Invalid value. The value of a reference in a ManyToMany " - . "association must be a Collection."); - } - - public static function invalidField($field) - { - return new self("Invalid field: '$field'."); - } -} \ No newline at end of file diff --git a/lib/Doctrine/EntityManager.php b/lib/Doctrine/EntityManager.php index 82a7400af..d13733276 100644 --- a/lib/Doctrine/EntityManager.php +++ b/lib/Doctrine/EntityManager.php @@ -350,7 +350,7 @@ class Doctrine_EntityManager public function setFlushMode($flushMode) { if ( ! $this->_isFlushMode($flushMode)) { - throw Doctrine_EntityManager_Exception::invalidFlushMode(); + throw Doctrine_ORM_Exceptions_EntityManagerException::invalidFlushMode(); } $this->_flushMode = $flushMode; } diff --git a/lib/Doctrine/EntityManager/Exception.php b/lib/Doctrine/EntityManager/Exception.php deleted file mode 100644 index 6e774b714..000000000 --- a/lib/Doctrine/EntityManager/Exception.php +++ /dev/null @@ -1,60 +0,0 @@ -. - */ - -#namespace Doctrine::ORM::Exceptions; - -/** - * Doctrine_EntityManager_Exception - * - * @author Konsta Vesterinen - * @author Roman Borschel - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.phpdoctrine.org - * @since 2.0 - * @version $Revision$ - */ -class Doctrine_EntityManager_Exception extends Doctrine_Exception -{ - public static function invalidFlushMode() - { - return new self("Invalid flush mode."); - } - - public static function noEntityManagerAvailable() - { - return new self("No EntityManager available."); - } - - public static function entityAlreadyBound($entityName) - { - return new self("The entity '$entityName' is already bound."); - } - - public static function noManagerWithName($emName) - { - return new self("EntityManager named '$emName' not found."); - } - - public static function unknownAttribute($name) - { - return new self("Unknown EntityManager attribute '$name'."); - } -} \ No newline at end of file diff --git a/tests/Orm/Component/AccessTest.php b/tests/Orm/Component/AccessTest.php index e27ccc478..da1394879 100644 --- a/tests/Orm/Component/AccessTest.php +++ b/tests/Orm/Component/AccessTest.php @@ -96,7 +96,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase /** * @test - * @expectedException Doctrine_Entity_Exception + * @expectedException Doctrine_ORM_Exceptions_EntityException */ public function shouldNotBeAbleToSetNonExistantField() { @@ -105,7 +105,7 @@ class Orm_Component_AccessTest extends Doctrine_OrmTestCase /** * @test - * @expectedException Doctrine_Entity_Exception + * @expectedException Doctrine_ORM_Exceptions_EntityException */ public function shouldNotBeAbleToSetNonExistantFieldWithOffset() { diff --git a/tests/Orm/EntityManagerTest.php b/tests/Orm/EntityManagerTest.php index 9509db18a..7ef9d9282 100644 --- a/tests/Orm/EntityManagerTest.php +++ b/tests/Orm/EntityManagerTest.php @@ -14,7 +14,7 @@ class Orm_EntityManagerTest extends Doctrine_OrmTestCase try { $this->_em->setFlushMode('foobar'); $this->fail("Setting invalid flushmode did not trigger exception."); - } catch (Doctrine_EntityManager_Exception $expected) {} + } catch (Doctrine_ORM_Exceptions_EntityManagerException $expected) {} $this->_em->setFlushMode($prev); } } \ No newline at end of file