8 '1' =>
"deferred update 1;\n",
9 '2' =>
"deferred update 2;\n",
10 '2-1' =>
"deferred update 1 within deferred update 2;\n",
11 '2-2' =>
"deferred update 2 within deferred update 2;\n",
12 '3' =>
"deferred update 3;\n",
13 '3-1' =>
"deferred update 1 within deferred update 3;\n",
14 '3-2' =>
"deferred update 2 within deferred update 3;\n",
15 '3-1-1' =>
"deferred update 1 within deferred update 1 within deferred update 3;\n",
16 '3-2-1' =>
"deferred update 1 within deferred update 2 with deferred update 3;\n",
18 DeferredUpdates::addCallableUpdate(
19 function ()
use ( $updates ) {
23 DeferredUpdates::addCallableUpdate(
24 function ()
use ( $updates ) {
26 DeferredUpdates::addCallableUpdate(
27 function ()
use ( $updates ) {
31 DeferredUpdates::addCallableUpdate(
32 function ()
use ( $updates ) {
38 DeferredUpdates::addCallableUpdate(
39 function ()
use ( $updates ) {
41 DeferredUpdates::addCallableUpdate(
42 function ()
use ( $updates ) {
44 DeferredUpdates::addCallableUpdate(
45 function ()
use ( $updates ) {
46 echo $updates[
'3-1-1'];
51 DeferredUpdates::addCallableUpdate(
52 function ()
use ( $updates ) {
54 DeferredUpdates::addCallableUpdate(
55 function ()
use ( $updates ) {
56 echo $updates[
'3-2-1'];
64 $this->assertEquals( 3, DeferredUpdates::pendingUpdatesCount() );
66 $this->expectOutputString( implode(
'', $updates ) );
68 DeferredUpdates::doUpdates();
72 DeferredUpdates::addCallableUpdate(
73 function ()
use ( &$x ) {
76 DeferredUpdates::PRESEND
78 DeferredUpdates::addCallableUpdate(
79 function ()
use ( &$y ) {
82 DeferredUpdates::POSTSEND
85 $this->assertNull( $x,
"Update not run yet" );
86 $this->assertNull( $y,
"Update not run yet" );
88 DeferredUpdates::doUpdates(
'run', DeferredUpdates::PRESEND );
89 $this->assertEquals(
"Sherity", $x,
"PRESEND update ran" );
90 $this->assertNull( $y,
"POSTSEND update not run yet" );
92 DeferredUpdates::doUpdates(
'run', DeferredUpdates::POSTSEND );
93 $this->assertEquals(
"Marychu", $y,
"POSTSEND update ran" );
99 '1' =>
"deferred update 1;\n",
100 '2' =>
"deferred update 2;\n",
101 '2-1' =>
"deferred update 1 within deferred update 2;\n",
102 '2-2' =>
"deferred update 2 within deferred update 2;\n",
103 '3' =>
"deferred update 3;\n",
104 '3-1' =>
"deferred update 1 within deferred update 3;\n",
105 '3-2' =>
"deferred update 2 within deferred update 3;\n",
106 '3-1-1' =>
"deferred update 1 within deferred update 1 within deferred update 3;\n",
107 '3-2-1' =>
"deferred update 1 within deferred update 2 with deferred update 3;\n",
112 DeferredUpdates::addCallableUpdate(
113 function ()
use ( $updates ) {
117 DeferredUpdates::addCallableUpdate(
118 function ()
use ( $updates ) {
120 DeferredUpdates::addCallableUpdate(
121 function ()
use ( $updates ) {
122 echo $updates[
'2-1'];
125 DeferredUpdates::addCallableUpdate(
126 function ()
use ( $updates ) {
127 echo $updates[
'2-2'];
132 DeferredUpdates::addCallableUpdate(
133 function ()
use ( $updates ) {
135 DeferredUpdates::addCallableUpdate(
136 function ()
use ( $updates ) {
137 echo $updates[
'3-1'];
138 DeferredUpdates::addCallableUpdate(
139 function ()
use ( $updates ) {
140 echo $updates[
'3-1-1'];
145 DeferredUpdates::addCallableUpdate(
146 function ()
use ( $updates ) {
147 echo $updates[
'3-2'];
148 DeferredUpdates::addCallableUpdate(
149 function ()
use ( $updates ) {
150 echo $updates[
'3-2-1'];
158 $this->expectOutputString( implode(
'', $updates ) );
160 DeferredUpdates::doUpdates();