-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid DB access in non-Database tests
When possible, mock the services which access the DB (one notable example is ChangeTagsStore in many API tests), or provide explicitly the data that would be looked up in the DB (e.g., Title content model). Add the test to the Database group otherwise. Change-Id: Icb3b3ad726bdcfcb64186cf2644d6d2bf3041c78
- Loading branch information
Showing
24 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use ApiPageSet; | ||
use ApiQuery; | ||
use MediaWiki\Request\FauxRequest; | ||
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait; | ||
use MediaWikiIntegrationTestCase; | ||
use RequestContext; | ||
use Status; | ||
|
@@ -32,6 +33,7 @@ | |
* @author Bene* < [email protected] > | ||
*/ | ||
class QuerySearchEntitiesTest extends MediaWikiIntegrationTestCase { | ||
use MockAuthorityTrait; | ||
|
||
/** | ||
* @param array $params | ||
|
@@ -42,6 +44,7 @@ private function getApiQuery( array $params ) { | |
$context = new RequestContext(); | ||
$context->setLanguage( 'en-ca' ); | ||
$context->setRequest( new FauxRequest( $params, true ) ); | ||
$context->setAuthority( $this->mockRegisteredNullAuthority() ); | ||
$main = new ApiMain( $context ); | ||
return $main->getModuleManager()->getModule( 'query' ); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Wikibase\Repo\Tests\Content; | ||
|
||
use MediaWiki\Page\WikiPageFactory; | ||
use ParserOutput; | ||
use Title; | ||
use Wikibase\DataModel\Entity\EntityDocument; | ||
|
@@ -25,6 +26,7 @@ | |
* @group WikibaseProperty | ||
* @group WikibaseEntity | ||
* @group WikibaseEntityHandler | ||
* @group Database | ||
* | ||
* @license GPL-2.0-or-later | ||
* @author Jeroen De Dauw < [email protected] > | ||
|
@@ -196,10 +198,12 @@ public function testDataForSearchIndex() { | |
} | ||
|
||
public function testGetParserOutput() { | ||
$this->setService( 'WikiPageFactory', $this->createMock( WikiPageFactory::class ) ); | ||
$content = $this->newEntityContent(); | ||
$contentRenderer = $this->getServiceContainer()->getContentRenderer(); | ||
|
||
$title = Title::makeTitle( NS_MAIN, 'Foo' ); | ||
$title->setContentModel( CONTENT_MODEL_WIKITEXT ); | ||
$parserOutput = $contentRenderer->getParserOutput( $content, $title ); | ||
|
||
$expectedUsedOptions = [ 'userlang', 'wb', 'termboxVersion' ]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.