Merge "Cleanup page creation in RevisionIntegrationTest"
[lhc/web/wiklou.git] / tests / phpunit / includes / deferred / MWCallableUpdateTest.php
1 <?php
2
3 /**
4 * @covers MWCallableUpdate
5 */
6 class MWCallableUpdateTest extends PHPUnit_Framework_TestCase {
7
8 public function testDoUpdate() {
9 $ran = 0;
10 $update = new MWCallableUpdate( function () use ( &$ran ) {
11 $ran++;
12 } );
13 $this->assertSame( 0, $ran );
14 $update->doUpdate();
15 $this->assertSame( 1, $ran );
16 }
17
18 public function testCancel() {
19 // Prepare update and DB
20 $db = new DatabaseTestHelper( __METHOD__ );
21 $db->begin( __METHOD__ );
22 $ran = 0;
23 $update = new MWCallableUpdate( function () use ( &$ran ) {
24 $ran++;
25 }, __METHOD__, $db );
26
27 // Emulate rollback
28 $db->rollback( __METHOD__ );
29
30 // Ensure it was cancelled
31 $update->doUpdate();
32 $this->assertSame( 0, $ran );
33 }
34 }