Skip to content

Commit

Permalink
tests: Remove use of AtEase
Browse files Browse the repository at this point in the history
Something somewhere is leaving error_reporting in a dirty state
causing AbuseFilter's ConsequencesExecutorTest case to fail for
the core change Ic9fee6cdd88001025.

Wikibase is one of the CI dependencies of AbuseFilter.

Per T253461, we're meant to eventually remove these anyway, so might
as well get it over with avoid its state problems, which are especially
fragile during tests where exceptions are not uncommon, thus not
reaching the restore call.

Change-Id: I2a665f09a357f2f2cc258d8c4011d49a7ab9c13b
  • Loading branch information
Krinkle committed Sep 16, 2021
1 parent 8f4bed1 commit 801349b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<!-- Exclude test methods like "testGivenInvalidInput_methodThrowsException". -->
<exclude-pattern>tests*Test*\.php</exclude-pattern>
</rule>
<rule ref="Generic.PHP.NoSilencedErrors.Discouraged">
<exclude-pattern>tests/phpunit/*</exclude-pattern>
</rule>

<!-- NOTE: We can not use the Squiz.Arrays.ArrayBracketSpacing sniff because it conflicts with
the MediaWiki style that encourages to use spaces inside brackets, see
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Site;
use SiteLookup;
use Wikibase\Client\OtherProjectsSitesGenerator;
use Wikimedia\AtEase\AtEase;

/**
* @covers \Wikibase\Client\OtherProjectsSitesGenerator
Expand Down Expand Up @@ -88,12 +87,10 @@ public function testOtherProjectSiteIds_unknownSite() {

// getOtherProjectsSiteIds does wfWarn in case it's being called with a siteid
// it doesn't know about. That's fine, we can just ignore that.
AtEase::suppressWarnings();
$result = $otherProjectsSitesProvider->getOtherProjectsSiteIds( [
$result = @$otherProjectsSitesProvider->getOtherProjectsSiteIds( [
'wikipedia',
'wikisource',
] );
AtEase::restoreWarnings();

$this->assertSame( [], $result );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Wikibase\Lib\Changes\EntityDiffChangedAspectsFactory;
use Wikibase\Lib\Changes\ItemChange;
use Wikibase\Lib\Tests\Changes\MockRepoClientCentralIdLookup;
use Wikimedia\AtEase\AtEase;
use Wikimedia\TestingAccessWrapper;

/**
Expand Down Expand Up @@ -463,9 +462,7 @@ public function testNewRecentChange_no_summary() {

$factory = $this->newRecentChangeFactory();

AtEase::suppressWarnings();
$rc = $factory->newRecentChange( $change, $target );
AtEase::restoreWarnings();
$rc = @$factory->newRecentChange( $change, $target );

$expectedComment = '(wikibase-comment-update)';
$this->assertEquals( $expectedComment, $rc->getAttribute( 'rc_comment' ) );
Expand Down
7 changes: 2 additions & 5 deletions repo/tests/phpunit/includes/PidLockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\Repo\Tests;

use Wikibase\Repo\PidLock;
use Wikimedia\AtEase\AtEase;

/**
* @covers \Wikibase\Repo\PidLock
Expand All @@ -25,10 +24,8 @@ public function testPidLock() {
$this->assertTrue( $pidLock->removeLock() );

// Make sure that the given file has actually been removed.
// unlink gives a warning if you use it a file that doesn't exist, suppress that
AtEase::suppressWarnings();
$this->assertFalse( $pidLock->removeLock() );
AtEase::restoreWarnings();
// ignore warning from unlink, e.g. if you use it a file that doesn't exist.
$this->assertFalse( @$pidLock->removeLock() );
}

}
5 changes: 1 addition & 4 deletions repo/tests/phpunit/includes/RepoHooksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Wikibase\Repo\RepoHooks;
use Wikibase\Repo\Store\RateLimitingIdGenerator;
use Wikibase\Repo\WikibaseRepo;
use Wikimedia\AtEase\AtEase;

/**
* @covers \Wikibase\Repo\RepoHooks
Expand Down Expand Up @@ -294,9 +293,7 @@ public function importProvider() {
*/
public function testImportHandleRevisionXMLTag_hook( $xml, $allowImport, $expectedException = null ) {
// WikiImporter tried to register this protocol every time, so unregister first to avoid errors.
AtEase::suppressWarnings();
stream_wrapper_unregister( 'uploadsource' );
AtEase::restoreWarnings();
@stream_wrapper_unregister( 'uploadsource' );

$this->getSettings()->setSetting( 'allowEntityImport', $allowImport );

Expand Down
8 changes: 1 addition & 7 deletions view/tests/phpunit/Template/TemplateRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Wikibase\View\Tests\Template;

use Wikibase\View\Template\TemplateRegistry;
use Wikimedia\AtEase\AtEase;

/**
* @covers \Wikibase\View\Template\TemplateRegistry
Expand Down Expand Up @@ -45,12 +44,7 @@ public function testGetKnownTemplate() {

public function testGetUnknownTemplate() {
$registry = new TemplateRegistry( [] );

AtEase::suppressWarnings();
$html = $registry->getTemplate( 'unknown' );
AtEase::restoreWarnings();

$this->assertNull( $html );
$this->assertNull( @$registry->getTemplate( 'unknown' ) );
}

}

0 comments on commit 801349b

Please sign in to comment.