public function provideGetWikiIdFromDomain() {
return [
- [ 'db-prefix', 'db-prefix' ],
+ [ 'db-prefix_', 'db-prefix_' ],
[ wfWikiID(), wfWikiID() ],
- [ new DatabaseDomain( 'db-dash', null, 'prefix' ), 'db-dash-prefix' ],
+ [ new DatabaseDomain( 'db-dash', null, 'prefix_' ), 'db-dash-prefix_' ],
[ wfWikiID(), wfWikiID() ],
- [ new DatabaseDomain( 'db-dash', null, 'prefix' ), 'db-dash-prefix' ],
- [ new DatabaseDomain( 'db', 'mediawiki', 'prefix' ), 'db-prefix' ], // schema ignored
- [ new DatabaseDomain( 'db', 'custom', 'prefix' ), 'db-custom-prefix' ],
+ [ new DatabaseDomain( 'db-dash', null, 'prefix_' ), 'db-dash-prefix_' ],
+ [ new DatabaseDomain( 'db', 'mediawiki', 'prefix_' ), 'db-prefix_' ], // schema ignored
+ [ new DatabaseDomain( 'db', 'custom', 'prefix_' ), 'db-custom-prefix_' ],
];
}
[ 'db', 'db', null, '' ],
[ 'db-schema-','db', 'schema', '' ],
[ 'db','db', 'mediawiki', '' ], // common b/c case
- [ 'db-prefix', 'db', null, 'prefix' ],
- [ 'db-schema-prefix', 'db', 'schema', 'prefix' ],
- [ 'db-prefix', 'db', 'mediawiki', 'prefix' ], // common b/c case
+ [ 'db-prefix_', 'db', null, 'prefix_' ],
+ [ 'db-schema-prefix_', 'db', 'schema', 'prefix_' ],
+ [ 'db-prefix_', 'db', 'mediawiki', 'prefix_' ], // common b/c case
// Bad hyphen cases (best effort support)
[ 'db-stuff', 'db-stuff', null, '' ],
- [ 'db-stuff-prefix', 'db-stuff', null, 'prefix' ],
+ [ 'db-stuff-prefix_', 'db-stuff', null, 'prefix_' ],
[ 'db-stuff-schema-', 'db-stuff', 'schema', '' ],
- [ 'db-stuff-schema-prefix', 'db-stuff', 'schema', 'prefix' ],
- [ 'db-stuff-prefix', 'db-stuff', 'mediawiki', 'prefix' ] // common b/c case
+ [ 'db-stuff-schema-prefix_', 'db-stuff', 'schema', 'prefix_' ],
+ [ 'db-stuff-prefix_', 'db-stuff', 'mediawiki', 'prefix_' ] // common b/c case
];
}
public static function provideConstruct() {
return [
'All strings' =>
- [ 'foo', 'bar', 'baz', 'foo-bar-baz' ],
+ [ 'foo', 'bar', 'baz_', 'foo-bar-baz_' ],
'Nothing' =>
[ null, null, '', '' ],
'Invalid $database' =>
'Invalid $prefix' =>
[ 'foo', 'bar', 0, '', true ],
'Dash' =>
- [ 'foo-bar', 'baz', 'baa', 'foo?hbar-baz-baa' ],
+ [ 'foo-bar', 'baz', 'baa_', 'foo?hbar-baz-baa_' ],
'Question mark' =>
- [ 'foo?bar', 'baz', 'baa', 'foo??bar-baz-baa' ],
+ [ 'foo?bar', 'baz', 'baa_', 'foo??bar-baz-baa_' ],
];
}
'Basic' =>
[ 'foo', 'foo', null, '' ],
'db+prefix' =>
- [ 'foo-bar', 'foo', null, 'bar' ],
+ [ 'foo-bar_', 'foo', null, 'bar_' ],
'db+schema+prefix' =>
- [ 'foo-bar-baz', 'foo', 'bar', 'baz' ],
+ [ 'foo-bar-baz_', 'foo', 'bar', 'baz_' ],
'?h -> -' =>
- [ 'foo?hbar-baz-baa', 'foo-bar', 'baz', 'baa' ],
+ [ 'foo?hbar-baz-baa_', 'foo-bar', 'baz', 'baa_' ],
'?? -> ?' =>
- [ 'foo??bar-baz-baa', 'foo?bar', 'baz', 'baa' ],
+ [ 'foo??bar-baz-baa_', 'foo?bar', 'baz', 'baa_' ],
'? is left alone' =>
- [ 'foo?bar-baz-baa', 'foo?bar', 'baz', 'baa' ],
+ [ 'foo?bar-baz-baa_', 'foo?bar', 'baz', 'baa_' ],
'too many parts' =>
- [ 'foo-bar-baz-baa', '', '', '', true ],
+ [ 'foo-bar-baz-baa_', '', '', '', true ],
'from instance' =>
[ DatabaseDomain::newUnspecified(), null, null, '' ],
];
'Basic' =>
[ 'foo', 'foo', null, '' ],
'db+prefix' =>
- [ 'foo-bar', 'foo', null, 'bar' ],
+ [ 'foo-bar_', 'foo', null, 'bar_' ],
'db+schema+prefix' =>
- [ 'foo-bar-baz', 'foo', 'bar', 'baz' ],
+ [ 'foo-bar-baz_', 'foo', 'bar', 'baz_' ],
'?h -> -' =>
- [ 'foo?hbar-baz-baa', 'foo-bar', 'baz', 'baa' ],
+ [ 'foo?hbar-baz-baa_', 'foo-bar', 'baz', 'baa_' ],
'?? -> ?' =>
- [ 'foo??bar-baz-baa', 'foo?bar', 'baz', 'baa' ],
+ [ 'foo??bar-baz-baa_', 'foo?bar', 'baz', 'baa_' ],
'Nothing' =>
[ '', null, null, '' ],
];
'Basic' =>
[ 'foo', 'foo', null, '', true ],
'db+prefix' =>
- [ 'foo-bar', 'foo', null, 'bar', true ],
+ [ 'foo-bar_', 'foo', null, 'bar_', true ],
'db+schema+prefix' =>
- [ 'foo-bar-baz', 'foo', 'bar', 'baz', true ],
+ [ 'foo-bar-baz_', 'foo', 'bar', 'baz_', true ],
'db+dontcare_schema+prefix' =>
- [ 'foo-bar-baz', 'foo', null, 'baz', false ],
+ [ 'foo-bar-baz_', 'foo', null, 'baz_', false ],
'?h -> -' =>
- [ 'foo?hbar-baz-baa', 'foo-bar', 'baz', 'baa', true ],
+ [ 'foo?hbar-baz-baa_', 'foo-bar', 'baz', 'baa_', true ],
'?? -> ?' =>
- [ 'foo??bar-baz-baa', 'foo?bar', 'baz', 'baa', true ],
+ [ 'foo??bar-baz-baa_', 'foo?bar', 'baz', 'baa_', true ],
'Nothing' =>
[ '', null, null, '', true ],
'dontcaredb+dontcaredbschema+prefix' =>
- [ 'mywiki-mediawiki-prefix', null, null, 'prefix', false ],
+ [ 'mywiki-mediawiki-prefix_', null, null, 'prefix_', false ],
'dontcaredb+schema+prefix' =>
- [ 'mywiki-schema-prefix', null, 'schema', 'prefix', false ],
+ [ 'mywiki-schema-prefix_', null, 'schema', 'prefix_', false ],
'db+dontcareschema+prefix' =>
- [ 'mywiki-schema-prefix', 'mywiki', null, 'prefix', false ],
+ [ 'mywiki-schema-prefix_', 'mywiki', null, 'prefix_', false ],
'postgres-db-jobqueue' =>
[ 'postgres-mediawiki-', 'postgres', null, '', false ]
];
public static function provideIsCompatible2() {
return [
'db+schema+prefix' =>
- [ 'mywiki-schema-prefix', 'thatwiki', 'schema', 'prefix' ],
+ [ 'mywiki-schema-prefix_', 'thatwiki', 'schema', 'prefix_' ],
'dontcaredb+dontcaredbschema+prefix' =>
- [ 'thatwiki-mediawiki-otherprefix', null, null, 'prefix' ],
+ [ 'thatwiki-mediawiki-otherprefix_', null, null, 'prefix_' ],
'dontcaredb+schema+prefix' =>
- [ 'mywiki-otherschema-prefix', null, 'schema', 'prefix' ],
+ [ 'mywiki-otherschema-prefix_', null, 'schema', 'prefix_' ],
'db+dontcareschema+prefix' =>
- [ 'notmywiki-schema-prefix', 'mywiki', null, 'prefix' ],
+ [ 'notmywiki-schema-prefix_', 'mywiki', null, 'prefix_' ],
];
}
$oldDomain = $this->db->getDomainId();
$this->assertInternalType( 'string', $old, 'Prefix is string' );
$this->assertSame( $old, $this->db->tablePrefix(), "Prefix unchanged" );
- $this->assertSame( $old, $this->db->tablePrefix( 'xxx' ) );
- $this->assertSame( 'xxx', $this->db->tablePrefix(), "Prefix set" );
+ $this->assertSame( $old, $this->db->tablePrefix( 'xxx_' ) );
+ $this->assertSame( 'xxx_', $this->db->tablePrefix(), "Prefix set" );
$this->db->tablePrefix( $old );
- $this->assertNotEquals( 'xxx', $this->db->tablePrefix() );
+ $this->assertNotEquals( 'xxx_', $this->db->tablePrefix() );
$this->assertSame( $oldDomain, $this->db->getDomainId() );
$old = $this->db->dbSchema();
$oldSchema = $this->db->dbSchema();
$oldPrefix = $this->db->tablePrefix();
- $this->db->selectDomain( 'testselectdb-xxx' );
+ $this->db->selectDomain( 'testselectdb-xxx_' );
$this->assertSame( 'testselectdb', $this->db->getDBname() );
$this->assertSame( '', $this->db->dbSchema() );
- $this->assertSame( 'xxx', $this->db->tablePrefix() );
+ $this->assertSame( 'xxx_', $this->db->tablePrefix() );
$this->db->selectDomain( $oldDomain );
$this->assertSame( $oldDatabase, $this->db->getDBname() );
$this->assertSame( $oldPrefix, $this->db->tablePrefix() );
$this->assertSame( $oldDomain, $this->db->getDomainId() );
- $this->db->selectDomain( 'testselectdb-schema-xxx' );
+ $this->db->selectDomain( 'testselectdb-schema-xxx_' );
$this->assertSame( 'testselectdb', $this->db->getDBname() );
$this->assertSame( 'schema', $this->db->dbSchema() );
- $this->assertSame( 'xxx', $this->db->tablePrefix() );
+ $this->assertSame( 'xxx_', $this->db->tablePrefix() );
$this->db->selectDomain( $oldDomain );
$this->assertSame( $oldDatabase, $this->db->getDBname() );