2009-02-28 23:22:12 +03:00
< ? php
namespace Doctrine\Tests\Common ;
2009-06-15 22:25:47 +04:00
require_once __DIR__ . '/../TestInit.php' ;
2009-02-28 23:22:12 +03:00
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') " );
}
2009-07-15 02:36:09 +04:00
public function testInnerException ()
{
$e1 = \Doctrine\Common\DoctrineException :: testException ();
$e2 = \Doctrine\Common\DoctrineException :: testException2 ( 'param1' , $e1 );
2009-07-24 15:33:38 +04:00
$this -> assertEquals ( $e1 , $e2 -> getPrevious ());
2009-07-15 02:36:09 +04:00
}
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 ());
}
2009-02-28 23:22:12 +03:00
}