5 require_once(CONST_LibDir.'/init-website.php');
6 require_once(CONST_LibDir.'/DatabaseError.php');
8 class DatabaseErrorTest extends \PHPUnit\Framework\TestCase
11 public function testSqlMessage()
13 $oSqlStub = $this->getMockBuilder(PDOException::class)
14 ->setMethods(array('getMessage'))
17 $oSqlStub->method('getMessage')
18 ->willReturn('Unknown table.');
20 $oErr = new DatabaseError('Sql error', 123, null, $oSqlStub);
21 $this->assertEquals('Sql error', $oErr->getMessage());
22 $this->assertEquals(123, $oErr->getCode());
23 $this->assertEquals('Unknown table.', $oErr->getSqlError());
26 public function testSqlObjectDump()
28 $oErr = new DatabaseError('Sql error', 123, null, array('one' => 'two'));
29 $this->assertStringContainsString('two', $oErr->getSqlDebugDump());