Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / includes / deferred / DeferredUpdatesTest.php
blob736f6e8909e420f062c17915000fa18f0733eb44
1 <?php
3 class DeferredUpdatesTest extends MediaWikiTestCase {
4 public function testDoUpdatesWeb() {
5 $this->setMwGlobals( 'wgCommandLineMode', false );
7 $updates = array(
8 '1' => 'deferred update 1',
9 '2' => 'deferred update 2',
10 '3' => 'deferred update 3',
11 '2-1' => 'deferred update 1 within deferred update 2',
13 DeferredUpdates::addCallableUpdate(
14 function () use ( $updates ) {
15 echo $updates['1'];
18 DeferredUpdates::addCallableUpdate(
19 function () use ( $updates ) {
20 echo $updates['2'];
21 DeferredUpdates::addCallableUpdate(
22 function () use ( $updates ) {
23 echo $updates['2-1'];
28 DeferredUpdates::addCallableUpdate(
29 function () use ( $updates ) {
30 echo $updates[3];
34 $this->expectOutputString( implode( '', $updates ) );
36 DeferredUpdates::doUpdates();
38 $x = null;
39 $y = null;
40 DeferredUpdates::addCallableUpdate(
41 function () use ( &$x ) {
42 $x = 'Sherity';
44 DeferredUpdates::PRESEND
46 DeferredUpdates::addCallableUpdate(
47 function () use ( &$y ) {
48 $y = 'Marychu';
50 DeferredUpdates::POSTSEND
53 $this->assertNull( $x, "Update not run yet" );
54 $this->assertNull( $y, "Update not run yet" );
56 DeferredUpdates::doUpdates( 'run', DeferredUpdates::PRESEND );
57 $this->assertEquals( "Sherity", $x, "PRESEND update ran" );
58 $this->assertNull( $y, "POSTSEND update not run yet" );
60 DeferredUpdates::doUpdates( 'run', DeferredUpdates::POSTSEND );
61 $this->assertEquals( "Marychu", $y, "POSTSEND update ran" );
64 public function testDoUpdatesCLI() {
65 $this->setMwGlobals( 'wgCommandLineMode', true );
67 $updates = array(
68 '1' => 'deferred update 1',
69 '2' => 'deferred update 2',
70 '2-1' => 'deferred update 1 within deferred update 2',
71 '3' => 'deferred update 3',
73 DeferredUpdates::addCallableUpdate(
74 function () use ( $updates ) {
75 echo $updates['1'];
78 DeferredUpdates::addCallableUpdate(
79 function () use ( $updates ) {
80 echo $updates['2'];
81 DeferredUpdates::addCallableUpdate(
82 function () use ( $updates ) {
83 echo $updates['2-1'];
88 DeferredUpdates::addCallableUpdate(
89 function () use ( $updates ) {
90 echo $updates[3];
94 $this->expectOutputString( implode( '', $updates ) );
96 DeferredUpdates::doUpdates();