summaryrefslogtreecommitdiff
path: root/www/wiki/tests/phpunit/includes/deferred/CdnCacheUpdateTest.php
blob: f3c949d3d0156e6af970cc9977834e528d03d6a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?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 );
	}
}