blob: 3ec632b8cd8870c78e93ea227f2408658925a81e (
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
<?php
namespace SMW\Tests\Integration\MediaWiki;
use SMW\MediaWiki\Search\Search;
use SMW\Tests\MwDBaseUnitTestCase;
use SMW\Tests\Utils\PageCreator;
use SMW\Tests\Utils\PageDeleter;
use Title;
/**
* @group SMW
* @group SMWExtension
*
* @group semantic-mediawiki-integration
* @group mediawiki-database
*
* @group medium
*
* @license GNU GPL v2+
* @since 2.1
*
* @author mwjames
*/
class SearchInPageDBIntegrationTest extends MwDBaseUnitTestCase {
public function testSearchForPageValueAsTerm() {
$propertyPage = Title::newFromText( 'Has some page value', SMW_NS_PROPERTY );
$targetPage = Title::newFromText( __METHOD__ );
$pageCreator = new PageCreator();
$pageCreator
->createPage( $propertyPage )
->doEdit( '[[Has type::Page]]' );
$pageCreator
->createPage( $targetPage )
->doEdit( '[[Has some page value::Foo]]' );
$this->testEnvironment->executePendingDeferredUpdates();
$search = new Search();
$results = $search->searchText( '[[Has some page value::Foo]]' );
$this->assertInstanceOf(
'\SMW\MediaWiki\Search\SearchResultSet',
$results
);
$this->assertEquals(
1,
$results->getTotalHits()
);
$pageDeleter = new PageDeleter();
$pageDeleter->deletePage( $targetPage );
$pageDeleter->deletePage( $propertyPage );
}
public function testSearchForGeographicCoordinateValueAsTerm() {
if ( !defined( 'SM_VERSION' ) ) {
$this->markTestSkipped( "Requires 'Geographic coordinate' to be a supported data type (see Semantic Maps)" );
}
$propertyPage = Title::newFromText( 'Has coordinates', SMW_NS_PROPERTY );
$targetPage = Title::newFromText( __METHOD__ );
$pageCreator = new PageCreator();
$pageCreator
->createPage( $propertyPage )
->doEdit( '[[Has type::Geographic coordinate]]' );
$pageCreator
->createPage( $targetPage )
->doEdit( "[[Has coordinates::52°31'N, 13°24'E]]" );
$this->testEnvironment->executePendingDeferredUpdates();
$search = new Search();
$results = $search->searchText( "[[Has coordinates::52°31'N, 13°24'E]]" );
$this->assertInstanceOf(
'\SMW\MediaWiki\Search\SearchResultSet',
$results
);
if ( is_a( $this->getStore(), '\SMW\SPARQLStore\SPARQLStore' ) ) {
$this->markTestIncomplete( "Test was marked as incomplete because the SPARQLStore doesn't support the Geo data type" );
}
$this->testEnvironment->executePendingDeferredUpdates();
$this->assertEquals(
1,
$results->getTotalHits()
);
$pageDeleter = new PageDeleter();
$pageDeleter->deletePage( $targetPage );
$pageDeleter->deletePage( $propertyPage );
}
}
|