Completed
Push — master ( 314506...335380 )
by mw
100:54 queued 62:54
created

SQLStore/RefreshSQLStoreDBIntegrationTest.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace SMW\Tests\Integration\SQLStore;
4
5
use SMW\Tests\MwDBaseUnitTestCase;
6
use SMW\Tests\Utils\MwHooksHandler;
7
use SMW\Tests\Utils\PageCreator;
8
use SMW\Tests\Utils\PageDeleter;
9
use Title;
10
use WikiPage;
11
12
/**
13
 *
14
 * @group SMW
15
 * @group SMWExtension
16
 * @group semantic-mediawiki-integration
17
 * @group mediawiki-database
18
 * @group medium
19
 *
20
 * @license GNU GPL v2+
21
 * @since 1.9
22
 *
23
 * @author mwjames
24
 */
25
class RefreshSQLStoreDBIntegrationTest extends MwDBaseUnitTestCase {
26
27
	private $title;
28
	private $mwHooksHandler;
29
	private $pageDeleter;
30
	private $pageCreator;
31
32
	protected function setUp() {
33
		parent::setUp();
34
35
		$this->mwHooksHandler = new MwHooksHandler();
36
		$this->pageDeleter = new PageDeleter();
37
		$this->pageCreator = new PageCreator();
38
	}
39
40
	public function tearDown() {
41
42
		$this->mwHooksHandler->restoreListedHooks();
43
44
		if ( $this->title !== null ) {
45
			$this->pageDeleter->deletePage( $this->title );
46
		}
47
48
		parent::tearDown();
49
	}
50
51
	/**
52
	 * @dataProvider titleProvider
53
	 */
54
	public function testAfterPageCreation_StoreHasDataToRefreshWithoutJobs( $ns, $name, $iw ) {
55
56
		$this->mwHooksHandler->deregisterListedHooks();
57
58
		$this->title = Title::makeTitle( $ns, $name, '', $iw );
59
60
		$this->pageCreator->createPage( $this->title  );
61
62
		$this->assertStoreHasDataToRefresh( false );
63
	}
64
65
	/**
66
	 * @dataProvider titleProvider
67
	 */
68
	public function testAfterPageCreation_StoreHasDataToRefreshWitJobs( $ns, $name, $iw ) {
69
70
		$this->mwHooksHandler->deregisterListedHooks();
71
72
		$this->title = Title::makeTitle( $ns, $name, '', $iw );
73
74
		$this->pageCreator->createPage( $this->title );
75
76
		$this->assertStoreHasDataToRefresh( true );
77
	}
78
79
	protected function assertStoreHasDataToRefresh( $useJobs ) {
80
		$refreshPosition = $this->title->getArticleID();
81
82
		$entityRebuildDispatcher = $this->getStore()->refreshData(
83
			$refreshPosition,
84
			1,
85
			false,
86
			$useJobs
87
		);
88
89
		$entityRebuildDispatcher->startRebuildWith( $refreshPosition );
0 ignored issues
show
The method startRebuildWith cannot be called on $entityRebuildDispatcher (of type double).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
90
91
		$this->assertGreaterThan(
92
			0,
93
			$entityRebuildDispatcher->getEstimatedProgress()
0 ignored issues
show
The method getEstimatedProgress cannot be called on $entityRebuildDispatcher (of type double).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
94
		);
95
	}
96
97
	public function titleProvider() {
98
		$provider = array();
99
100
	//	$provider[] = array( NS_MAIN, 'withInterWiki', 'commons' );
101
		$provider[] = array( NS_MAIN, 'normalTite', '' );
102
		$provider[] = array( NS_MAIN, 'useUpdateJobs', '' );
103
104
		return $provider;
105
	}
106
107
}
108