EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179035

Change subject: Fix phpunit failure in SpamBlacklistTest::testSpam
......................................................................

Fix phpunit failure in SpamBlacklistTest::testSpam

This test could fail depending on the execution order of the tests.
Essentially it depended on initializing the spam whitelists and
blacklists, but if the blacklist had already been initialized
this was ignored.

This patch resets the blacklist where appropriate so state is not
retained between tests.

Bug: T70655
Change-Id: I2a5d7d6ac3794973a1c67734414d4ba98ee640e6
---
M tests/phpunit/SpamFilter/SpamBlacklistTest.php
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/35/179035/1

diff --git a/tests/phpunit/SpamFilter/SpamBlacklistTest.php 
b/tests/phpunit/SpamFilter/SpamBlacklistTest.php
index 50b0b48..b36ccc4 100644
--- a/tests/phpunit/SpamFilter/SpamBlacklistTest.php
+++ b/tests/phpunit/SpamFilter/SpamBlacklistTest.php
@@ -2,6 +2,7 @@
 
 namespace Flow\Tests\SpamFilter;
 
+use BaseBlacklist;
 use Flow\Model\PostRevision;
 use Flow\SpamFilter\SpamBlacklist;
 use Flow\Tests\PostRevisionTestCase;
@@ -83,6 +84,11 @@
                $msgCache->enable();
                $msgCache->replace( 'Spam-blacklist', implode( "\n", 
$this->blacklist ) );
                $msgCache->replace( 'Spam-whitelist', implode( "\n", 
$this->whitelist ) );
+               // That only works if the spam blacklist is really reset
+               $instance = BaseBlacklist::getInstance( 'spam' );
+               $reflProp = new \ReflectionProperty( $instance, 'regexes' );
+               $reflProp->setAccessible( true );
+               $reflProp->setValue( $instance, false );
        }
 
        protected function tearDown() {

-- 
To view, visit https://gerrit.wikimedia.org/r/179035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a5d7d6ac3794973a1c67734414d4ba98ee640e6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to