1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SG\Tests\Integration; |
4
|
|
|
|
5
|
|
|
use SG\PropertyRegistrationHelper; |
6
|
|
|
|
7
|
|
|
use SMW\Tests\MwDBaseUnitTestCase; |
8
|
|
|
use SMW\Tests\Utils\UtilityFactory; |
9
|
|
|
|
10
|
|
|
use SMW\DIProperty; |
11
|
|
|
use SMW\DIWikiPage; |
12
|
|
|
|
13
|
|
|
use Title; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @ingroup Test |
17
|
|
|
* |
18
|
|
|
* @group SG |
19
|
|
|
* @group SGExtension |
20
|
|
|
* @group mediawiki-database |
21
|
|
|
* @group medium |
22
|
|
|
* |
23
|
|
|
* @license GNU GPL v2+ |
24
|
|
|
* @since 1.1 |
25
|
|
|
* |
26
|
|
|
* @author mwjames |
27
|
|
|
*/ |
28
|
|
|
class MwDBSQLStoreIntegrationTest extends MwDBaseUnitTestCase { |
29
|
|
|
|
30
|
|
|
private $pageCreator; |
31
|
|
|
private $pageDeleter; |
32
|
|
|
private $runnerFactory; |
33
|
|
|
|
34
|
|
|
protected function setUp() :void { |
35
|
|
|
parent::setUp(); |
36
|
|
|
|
37
|
|
|
$this->pageCreator = UtilityFactory::getInstance()->newPageCreator(); |
38
|
|
|
$this->pageDeleter = UtilityFactory::getInstance()->newPageDeleter(); |
39
|
|
|
$this->runnerFactory = UtilityFactory::getInstance()->newRunnerFactory(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testPageCreateDeleteStoreIntegration() { |
43
|
|
|
|
44
|
|
|
if ( !$this->isUsableUnitTestDatabase() ) { |
45
|
|
|
$this->markTestSkipped( |
46
|
|
|
'The database setup did not meet the test requirements' |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$title = Title::newFromText( __METHOD__ ); |
51
|
|
|
|
52
|
|
|
$this->pageCreator |
53
|
|
|
->createPage( $title ) |
54
|
|
|
->doEdit( "[[Glossary-Term::testTerm]] [[Glossary-Definition::testDefinition]]" ); |
55
|
|
|
|
56
|
|
|
$values = $this->getStore()->getPropertyValues( |
57
|
|
|
DIWikiPage::newFromTitle( $title ), |
58
|
|
|
new DIProperty( PropertyRegistrationHelper::SG_TERM ) |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
$this->assertNotEmpty( $values ); |
62
|
|
|
|
63
|
|
|
$this->pageDeleter |
64
|
|
|
->deletePage( $title ); |
65
|
|
|
|
66
|
|
|
$values = $this->getStore()->getPropertyValues( |
67
|
|
|
DIWikiPage::newFromTitle( $title ), |
68
|
|
|
new DIProperty( PropertyRegistrationHelper::SG_TERM ) |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$this->assertEmpty( $values ); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function testRebuildGlossaryCacheMaintenanceRun() { |
75
|
|
|
|
76
|
|
|
if ( !$this->isUsableUnitTestDatabase() ) { |
77
|
|
|
$this->markTestSkipped( |
78
|
|
|
'The database setup did not meet the test requirements' |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
$this->pageCreator |
83
|
|
|
->createPage( Title::newFromText( __METHOD__ ) ) |
84
|
|
|
->doEdit( "[[Glossary-Term::testTerm]] [[Glossary-Definition::testDefinition]]" ); |
85
|
|
|
|
86
|
|
|
$maintenanceRunner = $this->runnerFactory->newMaintenanceRunner( 'SG\Maintenance\RebuildGlossaryCache' ); |
87
|
|
|
|
88
|
|
|
$this->assertTrue( |
89
|
|
|
$maintenanceRunner->setQuiet()->run() |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|