blob: a3e67e64bc0ef8f335d76c92cd19b994e6144dc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
namespace SMW\Tests\MediaWiki\Deferred;
use SMW\MediaWiki\Deferred\ChangeTitleUpdate;
use SMW\Tests\TestEnvironment;
/**
* @covers \SMW\MediaWiki\Deferred\ChangeTitleUpdate
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class ChangeTitleUpdateTest extends \PHPUnit_Framework_TestCase {
private $testEnvironment;
private $jobFactory;
protected function setUp() {
parent::setUp();
$this->testEnvironment = new TestEnvironment();
$this->jobFactory = $this->getMockBuilder( '\SMW\MediaWiki\JobFactory' )
->disableOriginalConstructor()
->setMethods( [ 'newUpdateJob' ] )
->getMock();
$jobQueue = $this->getMockBuilder( '\SMW\MediaWiki\JobQueue' )
->disableOriginalConstructor()
->getMock();
$this->testEnvironment->registerObject( 'JobFactory', $this->jobFactory );
$this->testEnvironment->registerObject( 'JobQueue', $jobQueue );
}
protected function tearDown() {
$this->testEnvironment->clearPendingDeferredUpdates();
$this->testEnvironment->tearDown();
parent::tearDown();
}
public function testCanConstruct() {
$this->assertInstanceOf(
ChangeTitleUpdate::class,
new ChangeTitleUpdate()
);
}
public function testDoUpdate() {
$nullJob = $this->getMockBuilder( '\SMW\MediaWiki\Jobs\NullJob' )
->disableOriginalConstructor()
->getMock();
$this->jobFactory->expects( $this->atLeastOnce() )
->method( 'newUpdateJob' )
->will( $this->returnValue( $nullJob ) );
$oldTitle = $this->getMockBuilder( '\Title' )
->disableOriginalConstructor()
->getMock();
$newTitle = $this->getMockBuilder( '\Title' )
->disableOriginalConstructor()
->getMock();
$instance = new ChangeTitleUpdate(
$oldTitle,
$newTitle
);
$instance->doUpdate();
}
}
|