X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fdeferred%2FDeferredUpdatesTest.php;h=3b423563cace84fa3e5b8ab2ad13f5f190b700bb;hb=3daad1264bb80babc359f95843bd9b3d8ddc01e6;hp=d7ad1d1ed655c80058ee29c14f6fc0d0cd4b91b9;hpb=4feb2bd8d6deaee787f11ae8be41c0393934f636;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php index d7ad1d1ed6..3b423563ca 100644 --- a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php +++ b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php @@ -13,8 +13,7 @@ class DeferredUpdatesTest extends MediaWikiTestCase { $post = DeferredUpdates::POSTSEND; $all = DeferredUpdates::ALL; - $update = $this->getMockBuilder( 'DeferrableUpdate' ) - ->getMock(); + $update = $this->getMock( DeferrableUpdate::class ); $update->expects( $this->never() ) ->method( 'doUpdate' ); @@ -193,4 +192,30 @@ class DeferredUpdatesTest extends MediaWikiTestCase { DeferredUpdates::doUpdates(); } + + public function testPresendAddOnPostsendRun() { + $this->setMwGlobals( 'wgCommandLineMode', true ); + + $x = false; + $y = false; + wfGetLBFactory()->commitMasterChanges( __METHOD__ ); // clear anything + + DeferredUpdates::addCallableUpdate( + function () use ( &$x, &$y ) { + $x = true; + DeferredUpdates::addCallableUpdate( + function () use ( &$y ) { + $y = true; + }, + DeferredUpdates::PRESEND + ); + }, + DeferredUpdates::POSTSEND + ); + + DeferredUpdates::doUpdates(); + + $this->assertTrue( $x, "Outer POSTSEND update ran" ); + $this->assertTrue( $y, "Nested PRESEND update ran" ); + } }