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 @@ -<?php -/* - * $Id$ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see - * <http://www.phpdoctrine.org>. - */ - -#namespace Doctrine::ORM; - -/** - * Doctrine_Entity_Exception - * - * @package Doctrine - * @subpackage Entity - * @author Konsta Vesterinen <kvesteri@cc.hut.fi> - * @author Roman Borschel <roman@code-factory.org> - * @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 @@ -<?php -/* - * $Id$ - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * and is licensed under the LGPL. For more information, see - * <http://www.phpdoctrine.org>. - */ - -#namespace Doctrine::ORM::Exceptions; - -/** - * Doctrine_EntityManager_Exception - * - * @author Konsta Vesterinen <kvesteri@cc.hut.fi> - * @author Roman Borschel <roman@code-factory.org> - * @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