DBALExceptionTest.php 852 Bytes
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\Tests\DBAL;

use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\Exception\DriverException;
7 8 9 10 11

class DBALExceptionTest extends \Doctrine\Tests\DbalTestCase
{
    public function testDriverExceptionDuringQueryAcceptsBinaryData()
    {
12 13
        $driver = $this->getMock('\Doctrine\DBAL\Driver');
        $e = DBALException::driverExceptionDuringQuery($driver, new \Exception, '', array('ABC', chr(128)));
14 15
        $this->assertContains('with params ["ABC", "\x80"]', $e->getMessage());
    }
16 17 18 19 20 21 22 23

    public function testAvoidOverWrappingOnDriverException()
    {
        $driver = $this->getMock('\Doctrine\DBAL\Driver');
        $ex = new DriverException('', $this->getMock('\Doctrine\DBAL\Driver\DriverException'));
        $e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
        $this->assertSame($ex, $e);
    }
24
}