Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #349 from FabioBatSilva/DDC-1822

Fix DDC-1822
  • Loading branch information...
commit 3d8e46447a4fa8871bd268e8ad69820c636e0dea 2 parents 4ef552e + 0af5da7
@guilhermeblanco guilhermeblanco authored
View
2  lib/Doctrine/ORM/NoResultException.php
@@ -25,7 +25,7 @@
* @author robo
* @since 2.0
*/
-class NoResultException extends ORMException
+class NoResultException extends UnexpectedResultException
{
public function __construct()
{
View
5 lib/Doctrine/ORM/NonUniqueResultException.php
@@ -25,4 +25,7 @@
* @author robo
* @since 2.0
*/
-class NonUniqueResultException extends ORMException {}
+class NonUniqueResultException extends UnexpectedResultException
+{
+
+}
View
31 lib/Doctrine/ORM/UnexpectedResultException.php
@@ -0,0 +1,31 @@
+<?php
+/*
+ * 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.doctrine-project.org>.
+ */
+
+namespace Doctrine\ORM;
+
+/**
+ * Exception for a unexpected query result.
+ *
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ * @since 2.3
+ */
+class UnexpectedResultException extends ORMException
+{
+
+}
View
37 tests/Doctrine/Tests/ORM/Functional/QueryTest.php
@@ -619,4 +619,41 @@ public function testSetParameterBindingSingleIdentifierObjectConverted()
$this->assertEquals($userC->id, $q->getParameter(1));
}
+
+
+ /**
+ * @group DDC-1822
+ */
+ public function testUnexpectedResultException()
+ {
+ $dql = "SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u";
+ $u1 = new CmsUser;
+ $u2 = new CmsUser;
+ $u1->name = 'Fabio B. Silva';
+ $u1->username = 'FabioBatSilva';
+ $u1->status = 'developer';
+ $u2->name = 'Test';
+ $u2->username = 'test';
+ $u2->status = 'tester';
+
+ try {
+ $this->_em->createQuery($dql)->getSingleResult();
+ $this->fail('Expected exception "\Doctrine\ORM\NoResultException".');
+ } catch (\Doctrine\ORM\UnexpectedResultException $exc) {
+ $this->assertInstanceOf('\Doctrine\ORM\NoResultException', $exc);
+ }
+
+
+ $this->_em->persist($u1);
+ $this->_em->persist($u2);
+ $this->_em->flush();
+ $this->_em->clear();
+
+ try {
+ $this->_em->createQuery($dql)->getSingleResult();
+ $this->fail('Expected exception "\Doctrine\ORM\NonUniqueResultException".');
+ } catch (\Doctrine\ORM\UnexpectedResultException $exc) {
+ $this->assertInstanceOf('\Doctrine\ORM\NonUniqueResultException', $exc);
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.