DoctrineExceptionTest.php 1.38 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\Tests\Common;

romanb's avatar
romanb committed
5 6
require_once __DIR__ . '/../TestInit.php';

7 8 9 10 11 12 13 14
class DoctrineExceptionTest extends \Doctrine\Tests\DoctrineTestCase
{
    public function testStaticCall()
    {
        $e = \Doctrine\Common\DoctrineException::testingStaticCallBuildsErrorMessageWithParams('param1', 'param2');

        $this->assertEquals($e->getMessage(), "Testing static call builds error message with params ('param1', 'param2')");
    }
jwage's avatar
jwage committed
15 16 17 18 19

    public function testInnerException()
    {
        $e1 = \Doctrine\Common\DoctrineException::testException();
        $e2 = \Doctrine\Common\DoctrineException::testException2('param1', $e1);
romanb's avatar
romanb committed
20
        $this->assertEquals($e1, $e2->getPrevious());
jwage's avatar
jwage committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    }

    public function testNotImplemented()
    {
        $e = \Doctrine\Common\DoctrineException::notImplemented('testMethod', 'SomeClass');
        $this->assertEquals("The method 'testMethod' is not implemented in class 'SomeClass'.", $e->getMessage());
    }

    public function testGetExceptionMessage()
    {
        $this->assertEquals('The query contains more than one result.', \Doctrine\Common\DoctrineException::getExceptionMessage('QueryException#nonUniqueResult'));
    }

    public function testUseGetExceptionMessage()
    {
        $q = \Doctrine\ORM\Query\QueryException::nonUniqueResult();
        $this->assertEquals('The query contains more than one result.', $q->getMessage());
    }
39
}