jenkins-bot has submitted this change and it was merged.
Change subject: Disable shared SpamBlacklist during tests.
......................................................................
Disable shared SpamBlacklist during tests.
This defaults to meta, which we definitely don't want during unit
tests (and maybe don't want at all).
Bug: T89052
Change-Id: I0882f1720454f342b456209ad1bc5cd591ba51bf
---
M tests/phpunit/FlowTestCase.php
M tests/phpunit/SpamFilter/SpamBlacklistTest.php
M tests/phpunit/api/ApiTestCase.php
3 files changed, 39 insertions(+), 5 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/FlowTestCase.php b/tests/phpunit/FlowTestCase.php
index 7f0cc44..7fa87db 100644
--- a/tests/phpunit/FlowTestCase.php
+++ b/tests/phpunit/FlowTestCase.php
@@ -2,9 +2,42 @@
namespace Flow\Tests;
+use Status;
+
+use Flow\Container;
use Flow\Model\UUID;
class FlowTestCase extends \MediaWikiTestCase {
+ protected function setUp() {
+ self::useTestObjectsInContainer( $this );
+
+ parent::setUp();
+ }
+
+ /**
+ * Add testing versions of objects to dependency injection container
+ * This is meant to be done for all Flow tests. However, there is no
common
+ * base class since ApiTestCase does not extend from FlowTestCase.
+ *
+ * So this has to be exposed publically.
+ *
+ * @param MediaWikiTestCase $testCase Required so the Mock Builder API
can be used
+ */
+ public static function useTestObjectsInContainer( $testCase ) {
+ // Override dependency injection container to create test
environment
+ $container = Container::getContainer();
+
+ // In the test where we actually test
Flow\SpamFilter\SpamBlacklist, we
+ // don't use the container to get this.
+ $stub =
$testCase->getMockBuilder('Flow\\SpamFilter\\SpamBlacklist')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $stub->expects($testCase->any())
+ ->method( 'validate' )
+ ->will( $testCase->returnValue( Status::newGood() ) );
+ $container['controller.spamblacklist'] = $stub;
+ }
/**
* @param mixed $data
diff --git a/tests/phpunit/SpamFilter/SpamBlacklistTest.php
b/tests/phpunit/SpamFilter/SpamBlacklistTest.php
index b36ccc4..fb09b01 100644
--- a/tests/phpunit/SpamFilter/SpamBlacklistTest.php
+++ b/tests/phpunit/SpamFilter/SpamBlacklistTest.php
@@ -72,11 +72,9 @@
$this->markTestSkipped( 'SpamBlacklist not enabled' );
}
- // alter $wgMemc & write empty shared blacklist, to prevent an
attempt
- // to fetch spam blacklist over network
- $this->setMwGlobals( 'wgMemc', new \HashBagOStuff() );
- global $wgMemc, $wgDBname;
- $wgMemc->set( "$wgDBname:spam_blacklist_regexes", array() );
+ $this->setMwGlobals( 'wgBlacklistSettings', array(
+ 'files' => array(),
+ ) );
// local spam lists are read from spam-blacklist &
spam-whitelist
// messages, so change them for this test
diff --git a/tests/phpunit/api/ApiTestCase.php
b/tests/phpunit/api/ApiTestCase.php
index 030c44f..3ff7b47 100644
--- a/tests/phpunit/api/ApiTestCase.php
+++ b/tests/phpunit/api/ApiTestCase.php
@@ -22,6 +22,9 @@
// blank for testing read operations on unused (but
occupied) pages.
'Talk:Intentionally blank',
) );
+
+ \Flow\Tests\FlowTestCase::useTestObjectsInContainer( $this );
+
parent::setUp();
}
--
To view, visit https://gerrit.wikimedia.org/r/189614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0882f1720454f342b456209ad1bc5cd591ba51bf
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits