1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
4
|
|
|
|
5
|
|
|
namespace Maps\Tests\System\SemanticMW; |
6
|
|
|
|
7
|
|
|
use Maps\DataAccess\PageContentFetcher; |
8
|
|
|
use Maps\MapsFactory; |
9
|
|
|
use Maps\Tests\Util\PageCreator; |
10
|
|
|
use Maps\Tests\Util\TestFactory; |
11
|
|
|
use PHPUnit\Framework\TestCase; |
12
|
|
|
use Title; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @licence GNU GPL v2+ |
16
|
|
|
* @author Jeroen De Dauw < [email protected] > |
17
|
|
|
*/ |
18
|
|
|
class MapQueryTest extends TestCase { |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var PageCreator |
22
|
|
|
*/ |
23
|
|
|
private $pageCreator; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var PageContentFetcher |
27
|
|
|
*/ |
28
|
|
|
private $contentFetcher; |
29
|
|
|
|
30
|
|
|
public function setUp() { |
31
|
|
|
$this->pageCreator = TestFactory::newInstance()->getPageCreator(); |
32
|
|
|
$this->contentFetcher = MapsFactory::globalInstance()->getPageContentFetcher(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function testMapQuery() { |
36
|
|
|
$this->createPages(); |
37
|
|
|
|
38
|
|
|
$this->pageCreator->createPage( |
39
|
|
|
'MapQuery', |
40
|
|
|
'{{#ask:[[Coordinates::+]]|?Coordinates|?Description|?URL|format=map}}' |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
// TODO: saner way |
44
|
|
|
$content = $this->contentFetcher->getPageContent( 'MapQuery' )->getParserOutput( Title::newFromText( 'MapQuery' ) )->getText(); |
45
|
|
|
|
46
|
|
|
$this->assertContains( |
47
|
|
|
'<div id="map_', |
48
|
|
|
$content |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
$this->assertContains( |
52
|
|
|
'<div id="map_', |
53
|
|
|
$content |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private function createPages() { |
58
|
|
|
$this->pageCreator->createPage( |
59
|
|
|
'Property:Coordinates', |
60
|
|
|
'[[Has type::Geographic coordinate|geographic coordinate]]' |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
$this->pageCreator->createPage( |
64
|
|
|
'Property:Description', |
65
|
|
|
'[[Has type::Text]]' |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
$this->pageCreator->createPage( |
69
|
|
|
'Property:URL', |
70
|
|
|
'[[Has type::URL]]' |
71
|
|
|
); |
72
|
|
|
|
73
|
|
|
$this->pageCreator->createPage( |
74
|
|
|
'Berlin', |
75
|
|
|
'[[Coordinates::52° 31\' 0", 13° 24\' 0"]] [[Description::Capital of Germany]] [[URL::http://example.com/Berlin]]' |
76
|
|
|
); |
77
|
|
|
|
78
|
|
|
$this->pageCreator->createPage( |
79
|
|
|
'Brussels', |
80
|
|
|
'[[Coordinates::50° 51\' 1", 4° 21\' 6"]] [[Description::Capital of Belgium]]' |
81
|
|
|
); |
82
|
|
|
|
83
|
|
|
$this->pageCreator->createPage( |
84
|
|
|
'Hamburg', |
85
|
|
|
'[[Coordinates::53° 33\' 4", 9° 59\' 37"]]' |
86
|
|
|
); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|