1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
class AbstractSQLiteDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName() : void
{
$params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
'path' => 'bloo',
];
$connection = $this->getConnectionMock();
$connection->expects($this->once())
->method('getParams')
->will($this->returnValue($params));
self::assertSame($params['path'], $this->driver->getDatabase($connection));
}
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractSQLiteDriver::class);
}
protected function createPlatform() : AbstractPlatform
{
return new SqlitePlatform();
}
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new SqliteSchemaManager($connection);
}
/**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{
return [
self::EXCEPTION_CONNECTION => [
[0, null, 'unable to open database file'],
],
self::EXCEPTION_INVALID_FIELD_NAME => [
[0, null, 'has no column named'],
],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
[0, null, 'ambiguous column name'],
],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
[0, null, 'may not be NULL'],
],
self::EXCEPTION_READ_ONLY => [
[0, null, 'attempt to write a readonly database'],
],
self::EXCEPTION_SYNTAX_ERROR => [
[0, null, 'syntax error'],
],
self::EXCEPTION_TABLE_EXISTS => [
[0, null, 'already exists'],
],
self::EXCEPTION_TABLE_NOT_FOUND => [
[0, null, 'no such table:'],
],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
[0, null, 'must be unique'],
[0, null, 'is not unique'],
[0, null, 'are not unique'],
],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
[0, null, 'database is locked'],
],
];
}
}