Merge "Chinese Conversion Table Update 2017-6"
[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 use MediaWikiCoversValidator;
9
10 public function testDoUpdate() {
11 $ran = 0;
12 $update = new MWCallableUpdate( function () use ( &$ran ) {
13 $ran++;
14 } );
15 $this->assertSame( 0, $ran );
16 $update->doUpdate();
17 $this->assertSame( 1, $ran );
18 }
19
20 public function testCancel() {
21 // Prepare update and DB
22 $db = new DatabaseTestHelper( __METHOD__ );
23 $db->begin( __METHOD__ );
24 $ran = 0;
25 $update = new MWCallableUpdate( function () use ( &$ran ) {
26 $ran++;
27 }, __METHOD__, $db );
28
29 // Emulate rollback
30 $db->rollback( __METHOD__ );
31
32 // Ensure it was cancelled
33 $update->doUpdate();
34 $this->assertSame( 0, $ran );
35 }
36 }