Tobias Gritschacher has submitted this change and it was merged. Change subject: Made SetupTest run without actually accessing a real database ......................................................................
Made SetupTest run without actually accessing a real database This enabled running the test when using a DB different then MySQL and when not having a full MW setup Change-Id: I07071d18e1dd6e47d4ad6886fe9715900773aafc --- M QueryEngine/tests/phpunit/SQLStore/SetupTest.php 1 file changed, 26 insertions(+), 38 deletions(-) Approvals: Tobias Gritschacher: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/QueryEngine/tests/phpunit/SQLStore/SetupTest.php b/QueryEngine/tests/phpunit/SQLStore/SetupTest.php index 6e02d9b..72ae564 100644 --- a/QueryEngine/tests/phpunit/SQLStore/SetupTest.php +++ b/QueryEngine/tests/phpunit/SQLStore/SetupTest.php @@ -2,14 +2,11 @@ namespace Wikibase\Tests\QueryEngine\SQLStore; -use Wikibase\Database\MWDB\ExtendedMySQLAbstraction; -use Wikibase\Database\MediaWikiQueryInterface; use Wikibase\Database\TableBuilder; use Wikibase\QueryEngine\SQLStore\DataValueHandlers; use Wikibase\QueryEngine\SQLStore\Schema; use Wikibase\QueryEngine\SQLStore\Setup; use Wikibase\QueryEngine\SQLStore\StoreConfig; -use Wikibase\Repo\LazyDBConnectionProvider; /** * Unit tests for the Wikibase\QueryEngine\SQLStore\Setup class. @@ -40,30 +37,17 @@ * @licence GNU GPL v2+ * @author Jeroen De Dauw < [email protected] > */ -class SetupTest extends \MediaWikiTestCase { +class SetupTest extends \PHPUnit_Framework_TestCase { - /** - * @return \Wikibase\Database\QueryInterface - */ - protected function getQueryInterface() { - $connectionProvider = new LazyDBConnectionProvider( DB_MASTER ); - - $queryInterface = new MediaWikiQueryInterface( - $connectionProvider, - new ExtendedMySQLAbstraction( $connectionProvider ) - ); - - return $queryInterface; - } - - public function testExecutionOfRun() { + public function testInstall() { $defaultHandlers = new DataValueHandlers(); - $storeConfig = new StoreConfig( 'foo', 'wbsql_', $defaultHandlers->getHandlers() ); - $schema = new Schema( $storeConfig ); + $queryInterface = $this->getMock( 'Wikibase\Database\QueryInterface' ); - $queryInterface = $this->getQueryInterface(); + $queryInterface->expects( $this->atLeastOnce() ) + ->method( 'createTable' ) + ->will( $this->returnValue( true ) ); $storeSetup = new Setup( $storeConfig, @@ -72,23 +56,27 @@ new TableBuilder( $queryInterface ) ); - $this->assertTrue( $storeSetup->install() ); - - foreach ( $storeConfig->getDataValueHandlers() as $dvHandler ) { - foreach ( array( 'mainsnak_', 'qualifier_' ) as $snakLevel ) { - $table = $dvHandler->getDataValueTable()->getTableDefinition(); - $tableName = $storeConfig->getTablePrefix() . $snakLevel . $table->getName(); - - $this->assertTrue( - $queryInterface->tableExists( $tableName ), - 'Table "' . $tableName . '" should exist after store setup' - ); - } - } - - $this->assertTrue( $storeSetup->uninstall() ); + $storeSetup->install(); } - // TODO: add more detailed tests + public function testUninstall() { + $defaultHandlers = new DataValueHandlers(); + $storeConfig = new StoreConfig( 'foo', 'wbsql_', $defaultHandlers->getHandlers() ); + $schema = new Schema( $storeConfig ); + $queryInterface = $this->getMock( 'Wikibase\Database\QueryInterface' ); + + $queryInterface->expects( $this->atLeastOnce() ) + ->method( 'dropTable' ) + ->will( $this->returnValue( true ) ); + + $storeSetup = new Setup( + $storeConfig, + $schema, + $queryInterface, + new TableBuilder( $queryInterface ) + ); + + $storeSetup->uninstall(); + } } -- To view, visit https://gerrit.wikimedia.org/r/61041 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I07071d18e1dd6e47d4ad6886fe9715900773aafc Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <[email protected]> Gerrit-Reviewer: Daniel Werner <[email protected]> Gerrit-Reviewer: Tobias Gritschacher <[email protected]> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
