Jeroen De Dauw has submitted this change and it was merged. Change subject: Cleanup old files after they got moved out of Wikibase Lib and Wikibase Repo ......................................................................
Cleanup old files after they got moved out of Wikibase Lib and Wikibase Repo Change-Id: Id67e75f8542f9fd5e0ff0a855d052e48eda6379a --- D Query/EditQueryAction.php D Query/HistoryQueryAction.php D Query/ViewQueryAction.php A Tests/Phpunit/QueryContentTest.php A Tests/Phpunit/QueryHandlerTest.php A Tests/Phpunit/QueryTest.php R Tests/bootstrap.php R Tests/evilMediaWikiBootstrap.php D WikibaseQuery.classes.php M WikibaseQuery.php M composer.json M phpunit.xml.dist A src/Wikibase/Query/Actions/EditQueryAction.php A src/Wikibase/Query/Actions/HistoryQueryAction.php A src/Wikibase/Query/Actions/SubmitQueryAction.php A src/Wikibase/Query/Actions/ViewQueryAction.php R src/Wikibase/Query/QueryContent.php R src/Wikibase/Query/QueryEntity.php R src/Wikibase/Query/QueryHandler.php D tests/phpunit/QueryContentTest.php D tests/phpunit/QueryHandlerTest.php D tests/phpunit/QueryTest.php 22 files changed, 293 insertions(+), 413 deletions(-) Approvals: Denny Vrandecic: Looks good to me, approved Jeroen De Dauw: Verified diff --git a/Query/EditQueryAction.php b/Query/EditQueryAction.php deleted file mode 100644 index 921fedc..0000000 --- a/Query/EditQueryAction.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -namespace Wikibase; - -/** - * @file - * @ingroup WikibaseRepo - * @ingroup Action - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - * @author Daniel Kinzler - */ - -/** - * Handles the edit action for Wikibase queries. - * - * @since 0.1 - */ -class EditQueryAction extends EditEntityAction { - - - -} - -/** - * Handles the submit action for Wikibase queries. - * - * @since 0.1 - */ -class SubmitQueryAction extends SubmitEntityAction { - - - -} diff --git a/Query/HistoryQueryAction.php b/Query/HistoryQueryAction.php deleted file mode 100644 index de65906..0000000 --- a/Query/HistoryQueryAction.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace Wikibase; - -/** - * Handles the history action for Wikibase queries. - * - * @since 0.1 - * - * @file - * @ingroup WikibaseRepo - * @ingroup Action - * - * @licence GNU GPL v2+ - * @author John Erling Blad < [email protected] > - */ -class HistoryQueryAction extends HistoryEntityAction { - - - -} \ No newline at end of file diff --git a/Query/ViewQueryAction.php b/Query/ViewQueryAction.php deleted file mode 100644 index 59b3fc0..0000000 --- a/Query/ViewQueryAction.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -namespace Wikibase; - -/** - * Handles the view action for Wikibase queries. - * - * @since 0.1 - * - * @file - * @ingroup WikibaseRepo - * @ingroup Action - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -class ViewQueryAction extends ViewEntityAction { - - - -} \ No newline at end of file diff --git a/Tests/Phpunit/QueryContentTest.php b/Tests/Phpunit/QueryContentTest.php new file mode 100644 index 0000000..00a204b --- /dev/null +++ b/Tests/Phpunit/QueryContentTest.php @@ -0,0 +1,32 @@ +<?php + +namespace Wikibase\Test; + +/** + * @covers Wikibase\Query\QueryContent + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQuery + * @group WikibaseQuery + * @group Database + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < [email protected] > + */ +class QueryContentTest extends EntityContentTest { + + /** + * @see EntityContentTest::getContentClass + * + * @since 0.1 + * + * @return string + */ + protected function getContentClass() { + $this->markTestSkipped( 'This test still has to be made to work' ); + return '\Wikibase\Query\QueryContent'; + } + +} diff --git a/Tests/Phpunit/QueryHandlerTest.php b/Tests/Phpunit/QueryHandlerTest.php new file mode 100644 index 0000000..fd8e072 --- /dev/null +++ b/Tests/Phpunit/QueryHandlerTest.php @@ -0,0 +1,53 @@ +<?php + +namespace Wikibase\Test; + +use Wikibase\Query\QueryContent; + +/** + * @covers Wikibase\Query\QueryHandler + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQuery + * @group WikibaseQuery + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < [email protected] > + */ +class QueryHandlerTest extends EntityHandlerTest { + + /** + * @see EntityHandlerTest::getModelId + * @return string + */ + public function getModelId() { + return CONTENT_MODEL_WIKIBASE_QUERY; + } + + /** + * @see EntityHandlerTest::getClassName + * @return string + */ + public function getClassName() { + return '\Wikibase\Query\QueryHandler'; + } + + /** + * @see EntityHandlerTest::contentProvider + */ + public function contentProvider() { + $contents = parent::contentProvider(); + + /** + * @var QueryContent $content + */ + $content = clone $contents[1][0]; + // TODO: add some query-specific stuff: $content->getQuery()->; + $contents[] = array( $content ); + + return $contents; + } + +} \ No newline at end of file diff --git a/Tests/Phpunit/QueryTest.php b/Tests/Phpunit/QueryTest.php new file mode 100644 index 0000000..65c2f71 --- /dev/null +++ b/Tests/Phpunit/QueryTest.php @@ -0,0 +1,65 @@ +<?php + +namespace Wikibase\Test; + +use Ask\Language\Description\AnyValue; +use Ask\Language\Option\QueryOptions; +use Ask\Language\Query; +use Wikibase\Query\QueryEntity; + +/** + * @covers Wikibase\Query\QueryEntity + * + * @file + * @since 0.1 + * + * @ingroup WikibaseQuery + * @group WikibaseQuery + * + * @licence GNU GPL v2+ + * @author Jeroen De Dauw < [email protected] > + */ +class QueryTest extends EntityTest { + + /** + * @see EntityTest::getNewEmpty + * + * @since 0.1 + * + * @return Query + */ + protected function getNewEmpty() { + return QueryEntity::newEmpty(); + } + + /** + * @see EntityTest::getNewFromArray + * + * @since 0.1 + * + * @param array $data + * + * @return QueryEntity + */ + protected function getNewFromArray( array $data ) { + return QueryEntity::newFromArray( $data ); + } + + public function testSetQueryDefinition() { + $query = QueryEntity::newEmpty(); + + $queryDefinition = new Query( + new AnyValue(), + array(), + new QueryOptions( 1, 0 ) + ); + + $query->setQuery( $queryDefinition ); + + $obtainedDefinition = $query->getQuery(); + + $this->assertInstanceOf( 'Ask\Language\Query', $obtainedDefinition ); + $this->assertEquals( $queryDefinition, $obtainedDefinition ); + } + +} diff --git a/tests/bootstrap.php b/Tests/bootstrap.php similarity index 100% rename from tests/bootstrap.php rename to Tests/bootstrap.php diff --git a/tests/evilMediaWikiBootstrap.php b/Tests/evilMediaWikiBootstrap.php similarity index 100% rename from tests/evilMediaWikiBootstrap.php rename to Tests/evilMediaWikiBootstrap.php diff --git a/WikibaseQuery.classes.php b/WikibaseQuery.classes.php deleted file mode 100644 index 1b6ee48..0000000 --- a/WikibaseQuery.classes.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -/** - * Class registration file for the Wikibase Query extension. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @since 0.1 - * - * @file - * @ingroup WikibaseQuery - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -return call_user_func( function() { - - $classes = array( -// 'Wikibase\Query\', - ); - - $paths = array(); - - foreach ( $classes as $class ) { - $path = str_replace( '\\', '/', substr( $class, 9 ) ) . '.php'; - - $paths[$class] = $path; - } - - $paths['Wikibase\Query'] = 'Query/Query.php'; - - return $paths; - -} ); diff --git a/WikibaseQuery.php b/WikibaseQuery.php index 07a70ce..87ad7b9 100644 --- a/WikibaseQuery.php +++ b/WikibaseQuery.php @@ -36,23 +36,24 @@ return; } +define( 'WIKIBASE_QUERY_VERSION', '0.1 alpha' ); + global $wgExtensionCredits, $wgExtensionMessagesFiles, $wgAutoloadClasses, $wgHooks, $wgVersion; if ( version_compare( $wgVersion, '1.20c', '<' ) ) { die( '<b>Error:</b> Wikibase requires MediaWiki 1.20 or above.' ); } -if ( ( !defined( 'WB_VERSION' ) || !defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) - && is_readable( __DIR__ . '/vendor/autoload.php' ) ) { +if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { include_once( __DIR__ . '/vendor/autoload.php' ); } -if ( !defined( 'WB_VERSION' ) ) { - @include_once( __DIR__ . '/../Wikibase/repo/Wikibase.php' ); +if ( !defined( 'WB_VERSION' ) && is_readable( __DIR__ . '/../Wikibase/repo/Wikibase.php' ) ) { + include_once( __DIR__ . '/../Wikibase/repo/Wikibase.php' ); } -if ( !defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) { - @include_once( __DIR__ . '/../WikibaseQueryEngine/WikibaseQueryEngine.php' ); +if ( !defined( 'WIKIBASE_QUERYENGINE_VERSION' ) && is_readable( __DIR__ . '/../WikibaseQueryEngine/WikibaseQueryEngine.php' ) ) { + include_once( __DIR__ . '/../WikibaseQueryEngine/WikibaseQueryEngine.php' ); } if ( !defined( 'WB_VERSION' ) ) { @@ -62,8 +63,6 @@ if ( !defined( 'WIKIBASE_QUERYENGINE_VERSION' ) ) { throw new Exception( 'Wikibase Query depends on the Wikibase QueryEngine component.' ); } - -define( 'WIKIBASE_QUERY_VERSION', '0.1 alpha' ); $wgExtensionCredits['wikibase'][] = array( 'path' => __DIR__, @@ -78,13 +77,35 @@ $wgExtensionMessagesFiles['WikibaseQuery'] = __DIR__ . '/WikibaseQuery.i18n.php'; -foreach ( include( __DIR__ . '/WikibaseQuery.classes.php' ) as $class => $file ) { - $wgAutoloadClasses[$class] = __DIR__ . '/' . $file; -} +// @codeCoverageIgnoreStart +spl_autoload_register( function ( $className ) { + $className = ltrim( $className, '\\' ); + $fileName = ''; + $namespace = ''; + + if ( $lastNsPos = strripos( $className, '\\') ) { + $namespace = substr( $className, 0, $lastNsPos ); + $className = substr( $className, $lastNsPos + 1 ); + $fileName = str_replace( '\\', '/', $namespace ) . '/'; + } + + $fileName .= str_replace( '_', '/', $className ) . '.php'; + + $namespaceSegments = explode( '\\', $namespace ); + + if ( $namespaceSegments[0] === 'Wikibase' && count( $namespaceSegments ) > 1 && $namespaceSegments[1] === 'Query' ) { + if ( count( $namespaceSegments ) === 2 || $namespaceSegments[2] !== 'Tests' ) { + require_once __DIR__ . '/src/' . $fileName; + } + } +} ); +// @codeCoverageIgnoreEnd /** * Hook to add PHPUnit test cases. * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList + * + * @codeCoverageIgnore * * @since 0.1 * @@ -93,22 +114,18 @@ * @return boolean */ $wgHooks['UnitTestsList'][] = function( array &$files ) { - // @codeCoverageIgnoreStart - $testFiles = array( - 'Query', + $directoryIterator = new RecursiveDirectoryIterator( __DIR__ . '/Tests/Phpunit/' ); - // TODO: below tests are disabled since the EntityContentFactory has no proper registration - // system for new types of entities yet -// 'QueryContent', -// 'QueryHandler', - ); - - foreach ( $testFiles as $file ) { - $files[] = __DIR__ . '/tests/phpunit/' . $file . 'Test.php'; + /** + * @var SplFileInfo $fileInfo + */ + foreach ( new RecursiveIteratorIterator( $directoryIterator ) as $fileInfo ) { + if ( substr( $fileInfo->getFilename(), -8 ) === 'Test.php' ) { + $files[] = $fileInfo->getPathname(); + } } return true; - // @codeCoverageIgnoreEnd }; $wgWBRepoSettings['entityPrefixes']['y'] = 'query'; @@ -117,19 +134,9 @@ $wgHooks['FormatAutocomments'][] = array( 'Wikibase\Autocomment::onFormat', array( CONTENT_MODEL_WIKIBASE_QUERY, "wikibase-query" ) ); -$wgContentHandlers[CONTENT_MODEL_WIKIBASE_QUERY] = '\Wikibase\QueryHandler'; +$wgContentHandlers[CONTENT_MODEL_WIKIBASE_QUERY] = '\Wikibase\Query\QueryHandler'; $wgExtraNamespaces[WB_NS_QUERY] = 'Query'; $wgExtraNamespaces[WB_NS_QUERY_TALK] = 'Query_talk'; $wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_QUERY] = WB_NS_QUERY; - - -$wgAutoloadClasses['Wikibase\HistoryQueryAction'] = __DIR__ . '/Query/HistoryQueryAction.php'; -$wgAutoloadClasses['Wikibase\EditQueryAction'] = __DIR__ . '/Query/EditQueryAction.php'; -$wgAutoloadClasses['Wikibase\ViewQueryAction'] = __DIR__ . '/Query/ViewQueryAction.php'; -$wgAutoloadClasses['Wikibase\SubmitQueryAction'] = __DIR__ . '/Query/EditQueryAction.php'; - -$wgAutoloadClasses['Wikibase\QueryContent'] = __DIR__ . '/Query/QueryContent.php'; -$wgAutoloadClasses['Wikibase\QueryHandler'] = __DIR__ . '/Query/QueryHandler.php'; - diff --git a/composer.json b/composer.json index ab926c0..9a6024b 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "php": ">=5.3.0", "data-values/data-values": "dev-master", "ask/ask": "dev-master", - "wikibase/data-model": "dev-master", + "wikibase/data-model": ">=0.4", "wikibase/query-engine": "dev-master", "wikibase/wikibase": "dev-master" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8b84963..4ea344c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ <phpunit backupGlobals="false" backupStaticAttributes="false" - bootstrap="tests/bootstrap.php" + bootstrap="Tests/bootstrap.php" cacheTokens="false" colors="true" convertErrorsToExceptions="true" @@ -14,7 +14,7 @@ verbose="true"> <testsuites> <testsuite name="WikibaseQuery"> - <directory>tests/phpunit</directory> + <directory>Tests/Phpunit</directory> </testsuite> </testsuites> </phpunit> diff --git a/src/Wikibase/Query/Actions/EditQueryAction.php b/src/Wikibase/Query/Actions/EditQueryAction.php new file mode 100644 index 0000000..b9b7d11 --- /dev/null +++ b/src/Wikibase/Query/Actions/EditQueryAction.php @@ -0,0 +1,11 @@ +<?php + +namespace Wikibase\Query\Actions; + +use Wikibase\EditEntityAction; + +class EditQueryAction extends EditEntityAction { + + + +} diff --git a/src/Wikibase/Query/Actions/HistoryQueryAction.php b/src/Wikibase/Query/Actions/HistoryQueryAction.php new file mode 100644 index 0000000..14c2436 --- /dev/null +++ b/src/Wikibase/Query/Actions/HistoryQueryAction.php @@ -0,0 +1,11 @@ +<?php + +namespace Wikibase\Query\Actions; + +use Wikibase\HistoryEntityAction; + +class HistoryQueryAction extends HistoryEntityAction { + + + +} \ No newline at end of file diff --git a/src/Wikibase/Query/Actions/SubmitQueryAction.php b/src/Wikibase/Query/Actions/SubmitQueryAction.php new file mode 100644 index 0000000..76c26fd --- /dev/null +++ b/src/Wikibase/Query/Actions/SubmitQueryAction.php @@ -0,0 +1,11 @@ +<?php + +namespace Wikibase\Query\Actions; + +use Wikibase\SubmitEntityAction; + +class SubmitQueryAction extends SubmitEntityAction { + + + +} diff --git a/src/Wikibase/Query/Actions/ViewQueryAction.php b/src/Wikibase/Query/Actions/ViewQueryAction.php new file mode 100644 index 0000000..25b2544 --- /dev/null +++ b/src/Wikibase/Query/Actions/ViewQueryAction.php @@ -0,0 +1,11 @@ +<?php + +namespace Wikibase\Query\Actions; + +use Wikibase\ViewEntityAction; + +class ViewQueryAction extends ViewEntityAction { + + + +} \ No newline at end of file diff --git a/Query/QueryContent.php b/src/Wikibase/Query/QueryContent.php similarity index 86% rename from Query/QueryContent.php rename to src/Wikibase/Query/QueryContent.php index 71719f1..99077bd 100644 --- a/Query/QueryContent.php +++ b/src/Wikibase/Query/QueryContent.php @@ -1,7 +1,18 @@ <?php -namespace Wikibase; -use Title, Content, ParserOptions, ParserOutput, WikiPage, User, Status, DataUpdate; +namespace Wikibase\Query; + +use Title; +use Content; +use ParserOptions; +use ParserOutput; +use Wikibase\EntityContent; +use Wikibase\EntityDeletionUpdate; +use Wikibase\EntityModificationUpdate; +use WikiPage; +use User; +use Status; +use DataUpdate; /** * Content object for articles representing Wikibase queries. @@ -34,7 +45,7 @@ /** * @since 0.1 - * @var Query + * @var QueryEntity */ protected $query; @@ -46,9 +57,9 @@ * * @since 0.1 * - * @param Query $query + * @param QueryEntity $query */ - public function __construct( Query $query ) { + public function __construct( QueryEntity $query ) { parent::__construct( CONTENT_MODEL_WIKIBASE_QUERY ); $this->query = $query; @@ -59,11 +70,11 @@ * * @since 0.1 * - * @param Query $query + * @param QueryEntity $query * * @return QueryContent */ - public static function newFromQuery( Query $query ) { + public static function newFromQuery( QueryEntity $query ) { return new static( $query ); } @@ -77,7 +88,7 @@ * @return QueryContent */ public static function newFromArray( array $data ) { - return new static( new Query( $data ) ); + return new static( new QueryEntity( $data ) ); } /** @@ -109,7 +120,7 @@ * * @since 0.1 * - * @return Query + * @return QueryEntity */ public function getQuery() { return $this->query; @@ -120,9 +131,9 @@ * * @since 0.1 * - * @param Query $query + * @param QueryEntity $query */ - public function setQuery( Query $query ) { + public function setQuery( QueryEntity $query ) { $this->query = $query; } @@ -134,7 +145,7 @@ * @return QueryContent */ public static function newEmpty() { - return new static( Query::newEmpty() ); + return new static( QueryEntity::newEmpty() ); } /** @@ -142,7 +153,7 @@ * * @since 0.1 * - * @return Query + * @return QueryEntity */ public function getEntity() { return $this->query; diff --git a/Query/Query.php b/src/Wikibase/Query/QueryEntity.php similarity index 74% rename from Query/Query.php rename to src/Wikibase/Query/QueryEntity.php index 5a9cc66..3f7c831 100644 --- a/Query/Query.php +++ b/src/Wikibase/Query/QueryEntity.php @@ -1,9 +1,10 @@ <?php -namespace Wikibase; +namespace Wikibase\Query; -use Ask\Language\Query as QueryDefinition; +use Ask\Language\Query; use MWException; +use Wikibase\Entity; /** * Represents a single Wikibase query. @@ -32,32 +33,32 @@ * @licence GNU GPL v2+ * @author Jeroen De Dauw < [email protected] > */ -class Query extends Entity { +class QueryEntity extends Entity { const ENTITY_TYPE = 'query'; /** - * @since 0.4 + * @since 0.1 * - * @var QueryDefinition|null + * @var Query|null */ protected $queryDefinition = null; /** - * Returns the QueryDefinition of the query entity. + * Returns the Query of the query entity. * - * @since 0.4 + * @since 0.1 * - * @return QueryDefinition + * @return Query * @throws MWException */ - public function getQueryDefinition() { + public function getQuery() { if ( $this->queryDefinition === null ) { if ( array_key_exists( 'querydefinition', $this->data ) ) { // TODO } else { - throw new MWException( 'The QueryDefinition of the query is not known' ); + throw new MWException( 'The Query of the query is not known' ); } } @@ -65,13 +66,13 @@ } /** - * Sets the QueryDefinition of the query entity. + * Sets the Query of the query entity. * - * @since 0.4 + * @since 0.1 * - * @param QueryDefinition $queryDefinition + * @param Query $queryDefinition */ - public function setQueryDefinition( QueryDefinition $queryDefinition ) { + public function setQuery( Query $queryDefinition ) { $this->queryDefinition = $queryDefinition; } @@ -82,7 +83,7 @@ * * @param array $data * - * @return Query + * @return QueryEntity */ public static function newFromArray( array $data ) { return new static( $data ); @@ -91,7 +92,7 @@ /** * @since 0.1 * - * @return Query + * @return QueryEntity */ public static function newEmpty() { return self::newFromArray( array() ); @@ -105,7 +106,7 @@ * @return string */ public function getType() { - return Query::ENTITY_TYPE; + return QueryEntity::ENTITY_TYPE; } } diff --git a/Query/QueryHandler.php b/src/Wikibase/Query/QueryHandler.php similarity index 74% rename from Query/QueryHandler.php rename to src/Wikibase/Query/QueryHandler.php index fc3afa5..a20fc6d 100644 --- a/Query/QueryHandler.php +++ b/src/Wikibase/Query/QueryHandler.php @@ -1,7 +1,11 @@ <?php -namespace Wikibase; -use Title, ParserOutput; +namespace Wikibase\Query; + +use Title; +use ParserOutput; +use Wikibase\EntityFactory; +use Wikibase\EntityHandler; /** * Content handler for Wikibase items. @@ -38,12 +42,12 @@ /** * @see EntityHandler::getContentClass * - * @since 0.3 + * @since 0.1 * * @return string */ protected function getContentClass() { - return '\Wikibase\QueryContent'; + return '\Wikibase\Query\QueryContent'; } /** @@ -51,10 +55,10 @@ */ public function getActionOverrides() { return array( - 'history' => '\Wikibase\HistoryQueryAction', - 'view' => '\Wikibase\ViewQueryAction', - 'edit' => '\Wikibase\EditQueryAction', - 'submit' => '\Wikibase\SubmitQueryAction', + 'history' => '\Wikibase\Query\HistoryQueryAction', + 'view' => '\Wikibase\Query\ViewQueryAction', + 'edit' => '\Wikibase\Query\EditQueryAction', + 'submit' => '\Wikibase\Query\SubmitQueryAction', ); } @@ -69,20 +73,9 @@ * @return QueryContent */ public function unserializeContent( $blob, $format = null ) { - $entity = EntityFactory::singleton()->newFromBlob( Query::ENTITY_TYPE, $blob, $format ); + $entity = EntityFactory::singleton()->newFromBlob( QueryEntity::ENTITY_TYPE, $blob, $format ); return QueryContent::newFromQuery( $entity ); } - - /** - * @see ContentHandler::getDiffEngineClass - * - * @since 0.1 - * - * @return string - */ -// protected function getDiffEngineClass() { -// return '\Wikibase\QueryDiffView'; -// } } diff --git a/tests/phpunit/QueryContentTest.php b/tests/phpunit/QueryContentTest.php deleted file mode 100644 index d05d1cf..0000000 --- a/tests/phpunit/QueryContentTest.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -namespace Wikibase\Test; - -/** - * Tests for the Wikibase\QueryContent class. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @since 0.1 - * - * @ingroup WikibaseRepoTest - * @ingroup Test - * - * @group Database - * @group Wikibase - * @group WikibaseQuery - * @group WikibaseContent - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -class QueryContentTest extends EntityContentTest { - - /** - * @see EntityContentTest::getContentClass - * - * @since 0.1 - * - * @return string - */ - protected function getContentClass() { - return '\Wikibase\QueryContent'; - } - -} diff --git a/tests/phpunit/QueryHandlerTest.php b/tests/phpunit/QueryHandlerTest.php deleted file mode 100644 index 49e0ef8..0000000 --- a/tests/phpunit/QueryHandlerTest.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php - -namespace Wikibase\Test; -use \Wikibase\QueryContent; - -/** - * Tests for the Wikibase\QueryHandler class. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @since 0.1 - * - * @ingroup WikibaseRepoTest - * @ingroup Test - * - * @group Wikibase - * @group WikibaseQuery - * @group WikibaseEntity - * @group WikibaseEntityHandler - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -class QueryHandlerTest extends EntityHandlerTest { - - /** - * @see EntityHandlerTest::getModelId - * @return string - */ - public function getModelId() { - return CONTENT_MODEL_WIKIBASE_QUERY; - } - - /** - * @see EntityHandlerTest::getClassName - * @return string - */ - public function getClassName() { - return '\Wikibase\QueryHandler'; - } - - /** - * @see EntityHandlerTest::contentProvider - */ - public function contentProvider() { - $contents = parent::contentProvider(); - - /** - * @var QueryContent $content - */ - $content = clone $contents[1][0]; - // TODO: add some query-specific stuff: $content->getQuery()->; - $contents[] = array( $content ); - - return $contents; - } - -} \ No newline at end of file diff --git a/tests/phpunit/QueryTest.php b/tests/phpunit/QueryTest.php deleted file mode 100644 index 68f28fe..0000000 --- a/tests/phpunit/QueryTest.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -namespace Wikibase\Test; - -use Wikibase\Query; - -/** - * Tests for the Wikibase\Query class. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @file - * @since 0.1 - * - * @ingroup WikibaseLib - * @ingroup Test - * - * @group Wikibase - * @group WikibaseQuery - * - * @licence GNU GPL v2+ - * @author Jeroen De Dauw < [email protected] > - */ -class QueryTest extends EntityTest { - - /** - * @see EntityTest::getNewEmpty - * - * @since 0.1 - * - * @return \Wikibase\Query - */ - protected function getNewEmpty() { - return Query::newEmpty(); - } - - /** - * @see EntityTest::getNewFromArray - * - * @since 0.1 - * - * @param array $data - * - * @return \Wikibase\Entity - */ - protected function getNewFromArray( array $data ) { - return Query::newFromArray( $data ); - } - - public function testSetQueryDefinition() { - $query = Query::newEmpty(); - - $queryDefinition = new \Ask\Language\Query( - new \Ask\Language\Description\AnyValue(), - array(), - new \Ask\Language\Option\QueryOptions( 1, 0 ) - ); - - $query->setQueryDefinition( $queryDefinition ); - - $obtainedDefinition = $query->getQueryDefinition(); - - $this->assertInstanceOf( 'Ask\Language\Query', $obtainedDefinition ); - $this->assertEquals( $queryDefinition, $obtainedDefinition ); - } - -} -- To view, visit https://gerrit.wikimedia.org/r/72523 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id67e75f8542f9fd5e0ff0a855d052e48eda6379a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQuery Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <[email protected]> Gerrit-Reviewer: Daniel Werner <[email protected]> Gerrit-Reviewer: Denny Vrandecic <[email protected]> Gerrit-Reviewer: Jeroen De Dauw <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
