Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Fix compatibility with MW 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Nov 9, 2013
1 parent 40513fa commit ad9d24a
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 37 deletions.
8 changes: 7 additions & 1 deletion RELEASE-NOTES.md
@@ -1,13 +1,19 @@
These are the release notes for the [Wikibase Database library](README.md).

## Version 0.2 (under development)

* Removed custom autoloaders is favour of using the Composer autoloader.
* MediaWiki plugin: added compatibility with changes in MediaWiki 1.22.

## Version 0.1 (2013-11-01)

Initial release with the following features:

* QueryInterface interface for select, update, insert and delete queries.
* TableBuilder interface for table creation, deletion and existence checking.
* SchemaModifier interface for adding and removing fields and indexes.
* TableSlbBuilder, FieldSqlBuilder and IndexSqlBuilder interfaces for building SQL.
* TableSqlBuilder, FieldSqlBuilder and IndexSqlBuilder interfaces for building SQL.
* TableDefinition, FieldDefinition and IndexDefinition objects.
* MediaWiki plugin implementing the above interfaces.
* MySQL plugin providing implementations for all SQL builders.
* SQLite plugin providing implementations for all SQL builders.
6 changes: 3 additions & 3 deletions tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php
Expand Up @@ -29,7 +29,7 @@ public function testSetConnectionReturnsThis() {
$this->assertSame( $builder, $returnValue );
}

public function databaseTypeProvider(){
public function databaseTypeProvider() {
return array(
array( 'mysql', 'DatabaseMysql', $this->once() ),
array( 'sqlite', 'DatabaseSqlite', $this->never() ),
Expand All @@ -40,7 +40,7 @@ public function databaseTypeProvider(){
* @dataProvider databaseTypeProvider
*/
public function testGetQueryInterface( $type, $class, $getDBnameExpectsCount ) {
$connection = $this->getMock( $class );
$connection = $this->getMockBuilder( $class )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'getType' )
Expand All @@ -66,7 +66,7 @@ public function testGetQueryInterface( $type, $class, $getDBnameExpectsCount ) {
public function testUnsupportedDbType(){
$this->setExpectedException( 'RuntimeException', 'Cannot build a MediaWikiQueryInterface for database type' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();
$connection->expects( $this->once() )
->method( 'getType' )
->will( $this->returnValue( 'foobar' ) );
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php
Expand Up @@ -40,7 +40,7 @@ public function databaseTypeProvider(){
* @dataProvider databaseTypeProvider
*/
public function testGetDefinitionReader( $type, $class ) {
$connection = $this->getMock( $class );
$connection = $this->getMockBuilder( $class )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'getType' )
Expand All @@ -67,7 +67,7 @@ public function testGetDefinitionReader( $type, $class ) {
public function testUnsupportedDbType(){
$this->setExpectedException( 'RuntimeException', 'Cannot build a TableDefinitionReader for database type' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();
$connection->expects( $this->once() )
->method( 'getType' )
->will( $this->returnValue( 'foobar' ) );
Expand Down
10 changes: 7 additions & 3 deletions tests/phpunit/MediaWiki/MediaWikiEscaperTest.php
Expand Up @@ -18,14 +18,18 @@
class MediaWikiEscaperTest extends \PHPUnit_Framework_TestCase {

public function testCanConstruct() {
new MediaWikiEscaper( $this->getMock( 'DatabaseMysql' ) );
new MediaWikiEscaper( $this->newMockConnection() );
$this->assertTrue( true );
}

protected function newMockConnection() {
return $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();
}

public function testEscapeEmptyStringValue() {
$inputString = '';

$dbConnection = $this->getMock( 'DatabaseMysql' );
$dbConnection = $this->newMockConnection();

$dbConnection->expects( $this->once() )
->method( 'addQuotes' )
Expand All @@ -40,7 +44,7 @@ public function testEscapeEmptyStringValue() {
public function testEscapeEmptyStringIdentifier() {
$inputString = '';

$dbConnection = $this->getMock( 'DatabaseMysql' );
$dbConnection = $this->newMockConnection();

$dbConnection->expects( $this->once() )
->method( 'addIdentifierQuotes' )
Expand Down
20 changes: 10 additions & 10 deletions tests/phpunit/MediaWiki/MediaWikiQueryInterfaceTest.php
Expand Up @@ -24,7 +24,7 @@ class MediaWikiQueryInterfaceTest extends \PHPUnit_Framework_TestCase {
* @param string $tableName
*/
public function testTableExists( $tableName ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand Down Expand Up @@ -52,7 +52,7 @@ public function tableNameProvider() {
* @dataProvider insertProvider
*/
public function testInsert( $tableName, array $fieldValues ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand All @@ -76,7 +76,7 @@ public function testInsert( $tableName, array $fieldValues ) {
* @dataProvider insertProvider
*/
public function testInsertFailure( $tableName, array $fieldValues ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand Down Expand Up @@ -115,7 +115,7 @@ public function insertProvider() {
* @dataProvider updateProvider
*/
public function testUpdate( $tableName, array $newValues, array $conditions ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand All @@ -141,7 +141,7 @@ public function testUpdate( $tableName, array $newValues, array $conditions ) {
* @dataProvider updateProvider
*/
public function testUpdateFailure( $tableName, array $newValues, array $conditions ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand Down Expand Up @@ -203,7 +203,7 @@ public function updateProvider() {
* @dataProvider deleteProvider
*/
public function testDelete( $tableName, array $conditions ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand All @@ -224,7 +224,7 @@ public function testDelete( $tableName, array $conditions ) {
* @dataProvider deleteProvider
*/
public function testDeleteFailure( $tableName, array $conditions ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand Down Expand Up @@ -257,7 +257,7 @@ public function deleteProvider() {
}

public function testGetInsertId() {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand All @@ -274,7 +274,7 @@ public function testGetInsertId() {
* @dataProvider selectProvider
*/
public function testSelect( $tableName, array $fields, array $conditions ) {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$queryInterface = new MediaWikiQueryInterface(
new DirectConnectionProvider( $connection )
Expand Down Expand Up @@ -341,7 +341,7 @@ public function selectProvider() {

public function testSelectFailure() {
$this->setExpectedException( 'Wikibase\Database\QueryInterface\SelectFailedException' );
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();
$connection->expects( $this->once() )
->method( 'select' )
->will( $this->returnValue( 'FOOBAR' ) );
Expand Down
18 changes: 11 additions & 7 deletions tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php
Expand Up @@ -41,18 +41,18 @@ public function testSetQueryInterfaceReturnsThis() {
$this->assertSame( $builder, $returnValue );
}

public function databaseTypeProvider(){
public function databaseTypeProvider() {
return array(
array( 'mysql', 'DatabaseMysql' ),
array( 'sqlite', 'DatabaseSqlite'),
array( 'sqlite', 'DatabaseSqlite' ),
);
}

/**
* @dataProvider databaseTypeProvider
*/
public function testGetSchemaModifier( $type, $class ){
$connection = $this->getMock( $class );
public function testGetSchemaModifier( $type, $class ) {
$connection = $this->getMockBuilder( $class )->disableOriginalConstructor()->getMock();

$connection->expects( $this->atLeastOnce() )
->method( 'getType' )
Expand All @@ -79,7 +79,7 @@ public function testGetSchemaModifier( $type, $class ){
public function testUnsupportedDbType(){
$this->setExpectedException( 'RuntimeException', 'Cannot build a MediaWikiSchemaModifier for database type' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();
$connection->expects( $this->once() )
->method( 'getType' )
->will( $this->returnValue( 'foobar' ) );
Expand All @@ -102,8 +102,12 @@ public function testUnsupportedDbType(){
}

public function testSQLiteNeedsQueryInterface(){
$this->setExpectedException( 'RuntimeException', "Cannot build a MediaWikiSchemaModifier for database type 'SQLite' without queryInterface being defined" );
$connection = $this->getMock( 'DatabaseSqlite' );
$this->setExpectedException(
'RuntimeException',
"Cannot build a MediaWikiSchemaModifier for database type 'SQLite' without queryInterface being defined"
);

$connection = $this->getMockBuilder( 'DatabaseSqlite' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'getType' )
Expand Down
16 changes: 8 additions & 8 deletions tests/phpunit/MediaWiki/MediaWikiSchemaModifierTest.php
Expand Up @@ -40,7 +40,7 @@ public function testRemoveField() {
)
->will( $this->returnValue( $sql ) );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testAddField() {
)
->will( $this->returnValue( $sql ) );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testRemoveIndex() {
)
->will( $this->returnValue( $sql ) );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand Down Expand Up @@ -126,7 +126,7 @@ public function testAddIndex() {
)
->will( $this->returnValue( $sql ) );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand All @@ -143,7 +143,7 @@ public function testAddIndex() {
public function testRemoveFieldThrowsExceptionOnQueryFailure() {
$sqlBuilder = $this->getMock( 'Wikibase\Database\Schema\SchemaModificationSqlBuilder' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand All @@ -160,7 +160,7 @@ public function testRemoveFieldThrowsExceptionOnQueryFailure() {
public function testAddFieldThrowsExceptionOnQueryFailure() {
$sqlBuilder = $this->getMock( 'Wikibase\Database\Schema\SchemaModificationSqlBuilder' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand All @@ -180,7 +180,7 @@ public function testAddFieldThrowsExceptionOnQueryFailure() {
public function testRemoveIndexThrowsExceptionOnQueryFailure() {
$sqlBuilder = $this->getMock( 'Wikibase\Database\Schema\SchemaModificationSqlBuilder' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand All @@ -197,7 +197,7 @@ public function testRemoveIndexThrowsExceptionOnQueryFailure() {
public function testAddIndexThrowsExceptionOnQueryFailure() {
$sqlBuilder = $this->getMock( 'Wikibase\Database\Schema\SchemaModificationSqlBuilder' );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'query' )
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/MediaWiki/MediaWikiTableBuilderTest.php
Expand Up @@ -19,7 +19,7 @@
class MediaWikiTableBuilderTest extends \PHPUnit_Framework_TestCase {

protected function getBuilderAndDependencies() {
$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$tableSqlBuilder = $this->getMock( 'Wikibase\Database\Schema\TableSqlBuilder' );

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/MediaWiki/MediaWikiTableNameFormatterTest.php
Expand Up @@ -26,7 +26,7 @@ public function testFormatTableName() {
$prefix = 'prefix_';
$outputName = $prefix . $inputName;

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'tableName' )
Expand Down Expand Up @@ -61,7 +61,7 @@ public function testFormatTableNameWithExceptionFromDatabaseBase() {

$exception = new \Exception( $exceptionMessage );

$connection = $this->getMock( 'DatabaseMysql' );
$connection = $this->getMockBuilder( 'DatabaseMysql' )->disableOriginalConstructor()->getMock();

$connection->expects( $this->once() )
->method( 'tableName' )
Expand Down

0 comments on commit ad9d24a

Please sign in to comment.