Addshore has uploaded a new change for review. https://gerrit.wikimedia.org/r/89705
Change subject: Expand builder unit test for both db types ...................................................................... Expand builder unit test for both db types Change-Id: Ia2d02195d8ee5eeee891c8f9ca019f4e7c472a91 --- M tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php M tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php M tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php 3 files changed, 60 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseDatabase refs/changes/05/89705/1 diff --git a/tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php b/tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php index ec085d7..0e59ad2 100644 --- a/tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php +++ b/tests/phpunit/MediaWiki/MWTableBuilderBuilderTest.php @@ -29,14 +29,24 @@ $this->assertSame( $builder, $returnValue ); } - public function testGetQueryInterface() { - $connection = $this->getMock( 'DatabaseMysql' ); + public function databaseTypeProvider(){ + return array( + array( 'mysql', 'DatabaseMysql', $this->once() ), + array( 'sqlite', 'DatabaseSqlite', $this->exactly( 0 ) ), + ); + } + + /** + * @dataProvider databaseTypeProvider + */ + public function testGetQueryInterface( $type, $class, $getDBname ) { + $connection = $this->getMock( $class ); $connection->expects( $this->once() ) ->method( 'getType' ) - ->will( $this->returnValue( 'mysql' ) ); + ->will( $this->returnValue( $type ) ); - $connection->expects( $this->once() ) + $connection->expects( $getDBname ) ->method( 'getDBname' ) ->will( $this->returnValue( 'dbName' ) ); diff --git a/tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php b/tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php index c569bc8..c225fa4 100644 --- a/tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php +++ b/tests/phpunit/MediaWiki/MWTableDefinitionReaderTest.php @@ -29,12 +29,22 @@ $this->assertSame( $builder, $returnValue ); } - public function testGetDefinitionReader() { - $connection = $this->getMock( 'DatabaseMysql' ); + public function databaseTypeProvider(){ + return array( + array( 'mysql', 'DatabaseMysql' ), + array( 'sqlite', 'DatabaseSqlite'), + ); + } + + /** + * @dataProvider databaseTypeProvider + */ + public function testGetDefinitionReader( $type, $class ) { + $connection = $this->getMock( $class ); $connection->expects( $this->once() ) ->method( 'getType' ) - ->will( $this->returnValue( 'mysql' ) ); + ->will( $this->returnValue( $type ) ); $connectionProvider = $this->getMock( 'Wikibase\Database\DBConnectionProvider' ); diff --git a/tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php b/tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php index 0b4b4a4..3b0a38b 100644 --- a/tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php +++ b/tests/phpunit/MediaWiki/MediaWikiSchemaModifierBuilderTest.php @@ -41,12 +41,22 @@ $this->assertSame( $builder, $returnValue ); } - public function testGetSchemaModifier(){ - $connection = $this->getMock( 'DatabaseMysql' ); + public function databaseTypeProvider(){ + return array( + array( 'mysql', 'DatabaseMysql' ), + array( 'sqlite', 'DatabaseSqlite'), + ); + } + + /** + * @dataProvider databaseTypeProvider + */ + public function testGetSchemaModifier( $type, $class ){ + $connection = $this->getMock( $class ); $connection->expects( $this->once() ) ->method( 'getType' ) - ->will( $this->returnValue( 'mysql' ) ); + ->will( $this->returnValue( $type ) ); $connectionProvider = $this->getMock( 'Wikibase\Database\DBConnectionProvider' ); @@ -91,4 +101,24 @@ ->getSchemaModifier(); } + public function testSQLiteNeedsQueryInterface(){ + $this->setExpectedException( 'RuntimeException', "Cannot build a MediaWikiSchemaModifier for database type 'SQLite' without queryInterface being defined" ); + $connection = $this->getMock( 'DatabaseSqlite' ); + + $connection->expects( $this->once() ) + ->method( 'getType' ) + ->will( $this->returnValue( 'sqlite' ) ); + + $connectionProvider = $this->getMock( 'Wikibase\Database\DBConnectionProvider' ); + + $connectionProvider->expects( $this->atLeastOnce() ) + ->method( 'getConnection' ) + ->will( $this->returnValue( $connection ) ); + + $builder = new MediaWikiSchemaModifierBuilder(); + + $builder + ->setConnection( $connectionProvider ) + ->getSchemaModifier(); + } } \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/89705 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia2d02195d8ee5eeee891c8f9ca019f4e7c472a91 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseDatabase Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits