1 | <?php |
||
15 | class LocationParserTest extends \PHPUnit_Framework_TestCase { |
||
16 | |||
17 | public function setUp() { |
||
22 | |||
23 | /** |
||
24 | * @dataProvider titleProvider |
||
25 | */ |
||
26 | public function testGivenTitleThatIsNotLink_titleIsSetAndLinkIsNot( $title ) { |
||
32 | |||
33 | protected function assertTitleAndLinkAre( Location $location, $title, $link ) { |
||
34 | $this->assertHasJsonKeyWithValue( $location, 'title', $title ); |
||
35 | $this->assertHasJsonKeyWithValue( $location, 'link', $link ); |
||
36 | } |
||
37 | |||
38 | protected function assertHasJsonKeyWithValue( Location $polygon, $key, $value ) { |
||
39 | $json = $polygon->getJSONObject(); |
||
40 | |||
41 | $this->assertArrayHasKey( $key, $json ); |
||
42 | $this->assertEquals( $value, $json[$key] ); |
||
43 | } |
||
44 | |||
45 | public function titleProvider() { |
||
46 | return [ |
||
47 | [ '' ], |
||
48 | [ 'Title' ], |
||
49 | [ 'Some title' ], |
||
50 | [ 'link' ], |
||
51 | [ 'links:foo' ], |
||
52 | ]; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @dataProvider linkProvider |
||
57 | */ |
||
58 | public function testGivenTitleThatIsLink_linkIsSetAndTitleIsNot( $link ) { |
||
64 | |||
65 | public function linkProvider() { |
||
66 | return [ |
||
67 | [ 'https://www.semantic-mediawiki.org' ], |
||
71 | |||
72 | // /** |
||
73 | // * @dataProvider titleLinkProvider |
||
74 | // */ |
||
75 | // public function testGivenPageTitleAsLink_pageTitleIsTurnedIntoUrl( $link ) { |
||
76 | // $parser = new LocationParser(); |
||
77 | // $location = $parser->parse( '4,2~link:' . $link ); |
||
78 | // |
||
79 | // $linkUrl = Title::newFromText( $link )->getFullURL(); |
||
80 | // $this->assertTitleAndLinkAre( $location, '', $linkUrl ); |
||
81 | // } |
||
82 | // |
||
83 | // public function titleLinkProvider() { |
||
84 | // return array( |
||
85 | // array( 'Foo' ), |
||
86 | // array( 'Some_Page' ), |
||
87 | // ); |
||
88 | // } |
||
89 | |||
90 | public function testGivenAddressAndNoTitle_addressIsSetAsTitle() { |
||
98 | |||
99 | public function testGivenAddressAndTitle_addressIsNotUsedAsTitle() { |
||
107 | |||
108 | public function testGivenCoordinatesAndNoTitle_noTitleIsSet() { |
||
117 | |||
118 | } |
||
119 |