1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Tests; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use Yiisoft\Db\Tests\Support\TestTrait; |
9
|
|
|
|
10
|
|
|
abstract class AbstractQuoterTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
use TestTrait; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::ensureColumnName() |
16
|
|
|
*/ |
17
|
|
|
public function testEnsureColumnName(string $columnName, string $expected): void |
18
|
|
|
{ |
19
|
|
|
$db = $this->getConnection(); |
20
|
|
|
|
21
|
|
|
$this->assertSame($expected, $db->getQuoter()->ensureColumnName($columnName)); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::ensureNameQuoted() |
26
|
|
|
*/ |
27
|
|
|
public function testEnsureNameQuoted(string $name, string $expected): void |
28
|
|
|
{ |
29
|
|
|
$db = $this->getConnection(); |
30
|
|
|
|
31
|
|
|
$this->assertSame($expected, $db->getQuoter()->ensureNameQuoted($name)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::tableNameParts() |
36
|
|
|
*/ |
37
|
|
|
public function testGetTableNameParts(string $tableName, string ...$expected): void |
38
|
|
|
{ |
39
|
|
|
$db = $this->getConnection(); |
40
|
|
|
|
41
|
|
|
$this->assertSame($expected, array_reverse($db->getQuoter()->getTableNameParts($tableName))); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::columnName() |
46
|
|
|
*/ |
47
|
|
|
public function testQuoteColumnName(string $columnName, string $expected): void |
48
|
|
|
{ |
49
|
|
|
$db = $this->getConnection(); |
50
|
|
|
|
51
|
|
|
$this->assertSame($expected, $db->getQuoter()->quoteColumnName($columnName)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::columnName() |
56
|
|
|
*/ |
57
|
|
|
public function testQuoteSimpleColumnName(string $columnName, string $expected): void |
58
|
|
|
{ |
59
|
|
|
$db = $this->getConnection(); |
60
|
|
|
|
61
|
|
|
$this->assertSame($expected, $db->getQuoter()->quoteSimpleColumnName($columnName)); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::simpleTableName() |
66
|
|
|
*/ |
67
|
|
|
public function testQuoteSimpleTableName(string $columnName, string $expected): void |
68
|
|
|
{ |
69
|
|
|
$db = $this->getConnection(); |
70
|
|
|
|
71
|
|
|
$this->assertSame($expected, $db->getQuoter()->quoteSimpleTableName($columnName)); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::tableName() |
76
|
|
|
*/ |
77
|
|
|
public function testQuoteTableName(string $tableName, string $expected): void |
78
|
|
|
{ |
79
|
|
|
$db = $this->getConnection(); |
80
|
|
|
|
81
|
|
|
$this->assertSame($expected, $db->getQuoter()->quoteTableName($tableName)); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::unquoteSimpleColumnName() |
86
|
|
|
*/ |
87
|
|
|
public function testUnquoteSimpleColumnName(string $columnName, string $expected): void |
88
|
|
|
{ |
89
|
|
|
$db = $this->getConnection(); |
90
|
|
|
|
91
|
|
|
$this->assertSame($expected, $db->getQuoter()->unquoteSimpleColumnName($columnName)); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @dataProvider \Yiisoft\Db\Tests\Provider\QuoterProvider::unquoteSimpleTableName() |
96
|
|
|
*/ |
97
|
|
|
public function testUnquoteSimpleTableName(string $tableName, string $expected): void |
98
|
|
|
{ |
99
|
|
|
$db = $this->getConnection(); |
100
|
|
|
|
101
|
|
|
$this->assertSame($expected, $db->getQuoter()->unquoteSimpleTableName($tableName)); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|