From 1% of lines to 12% in deferred/.
From 6% of lines to 68% in DeferredUpdates.php.
* Adding relevant @covers tags to existing tests.
* Add coverage for MWCallableUpdate.
* Add coverage for MergeableUpdate.
Also:
* Make MergeableUpdate extend DeferrableUpdate.
1. Because PHPUnit doesn't support implementing multiple interfaces
in a mock, and would make the mock fail the typehint at run-time.
2. It DeferredUpdates doesn't support having a MergeableUpdate that isn't
itself a DeferrableUpdate given the only way to reach that code is past
methods that are type-hinted with DeferrableUpdate.
3. Making the interface extend DeferrableUpdate helps produce better and
earlier errors. Instead of run-time error:
> Argument 1 passed to addUpdate() must implement interface DeferrableUpdate
> instance of MergeableUpdate given
We get:
> Fatal error: Class .. contains 1 abstract method and must therefore be
> declared abstract or implement the remaining methods (doUpdate)
Change-Id: Ie384bf849a96bb37dc3e4a4154da2b02889e9fc8
31 lines
897 B
PHP
31 lines
897 B
PHP
<?php
|
|
|
|
use Wikimedia\TestingAccessWrapper;
|
|
|
|
class CdnCacheUpdateTest extends MediaWikiTestCase {
|
|
|
|
/**
|
|
* @covers CdnCacheUpdate::merge
|
|
*/
|
|
public function testPurgeMergeWeb() {
|
|
$this->setMwGlobals( 'wgCommandLineMode', false );
|
|
|
|
$urls1 = [];
|
|
$title = Title::newMainPage();
|
|
$urls1[] = $title->getCanonicalURL( '?x=1' );
|
|
$urls1[] = $title->getCanonicalURL( '?x=2' );
|
|
$urls1[] = $title->getCanonicalURL( '?x=3' );
|
|
$update1 = new CdnCacheUpdate( $urls1 );
|
|
DeferredUpdates::addUpdate( $update1 );
|
|
|
|
$urls2 = [];
|
|
$urls2[] = $title->getCanonicalURL( '?x=2' );
|
|
$urls2[] = $title->getCanonicalURL( '?x=3' );
|
|
$urls2[] = $title->getCanonicalURL( '?x=4' );
|
|
$update2 = new CdnCacheUpdate( $urls2 );
|
|
DeferredUpdates::addUpdate( $update2 );
|
|
|
|
$wrapper = TestingAccessWrapper::newFromObject( $update1 );
|
|
$this->assertEquals( array_merge( $urls1, $urls2 ), $wrapper->urls );
|
|
}
|
|
}
|