Debian Codegraph @

tests/phpunit/unit/includes/libs/rdbms/platform/PostgresPlatformTest.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21 namespace Wikimedia\Tests\Rdbms;
22
23 use MediaWiki\Tests\Unit\Libs\Rdbms\AddQuoterMock;
24 use MediaWikiCoversValidator;
25 use PHPUnit\Framework\TestCase;
26 use Wikimedia\Rdbms\DatabaseDomain;
27 use Wikimedia\Rdbms\Platform\PostgresPlatform;
28
29 /**
30 * @covers \Wikimedia\Rdbms\Platform\PostgresPlatform
31 */
32 class PostgresPlatformTest extends TestCase {
33
34 use MediaWikiCoversValidator;
35
36 /** @var PostgresPlatform */
37 private $platform;
38
39 protected function setUp(): void {
40 parent::setUp();
41 $this->platform = new PostgresPlatform( new AddQuoterMock() );
42 }
43
44 public static function provideTableIdentifiers() {
45 yield [
46 'table',
47 new DatabaseDomain( 'database', null, '' ),
48 [ 'database', 'table' ]
49 ];
50 yield [
51 'database.table',
52 new DatabaseDomain( 'database', null, '' ),
53 [ 'database', 'table' ]
54 ];
55 yield [
56 'database.schema.table',
57 new DatabaseDomain( 'database', null, '' ),
58 [ 'database', 'table' ]
59 ];
60 yield [
61 '"database"."schema"."table"',
62 new DatabaseDomain( 'database', null, '' ),
63 [ 'database', 'table' ]
64 ];
65 yield [
66 '"database"."table"',
67 new DatabaseDomain( 'database', null, '' ),
68 [ 'database', 'table' ]
69 ];
70 }
71
72 /**
73 * @dataProvider provideTableIdentifiers
74 */
75 public function testGetDatabaseAndTableIdentifiers(
76 $tableName,
77 $domain,
78 $expectedIdentifiers
79 ) {
80 $platform = new PostgresPlatform( new AddQuoterMock(), null, $domain );
81
82 $this->assertSame(
83 $expectedIdentifiers,
84 $platform->getDatabaseAndTableIdentifier( $tableName )
85 );
86 }
87 }