1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Maps\Tests\Integration\parsers; |
4
|
|
|
|
5
|
|
|
use DataValues\Geo\Values\LatLongValue; |
6
|
|
|
use Jeroen\SimpleGeocoder\Geocoders\Decorators\CoordinateFriendlyGeocoder; |
7
|
|
|
use Jeroen\SimpleGeocoder\Geocoders\NullGeocoder; |
8
|
|
|
use Maps\Elements\Rectangle; |
9
|
|
|
use Maps\Presentation\WikitextParsers\RectangleParser; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \Maps\Presentation\WikitextParsers\RectangleParser |
14
|
|
|
* @licence GNU GPL v2+ |
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
16
|
|
|
*/ |
17
|
|
|
class RectangleParserTest extends TestCase { |
18
|
|
|
|
19
|
|
|
public function testGivenBoundingBox_parserReturnsRectangle() { |
20
|
|
|
$parser = new RectangleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) ); |
21
|
|
|
|
22
|
|
|
$rectangle = $parser->parse( '51.8357775,33.83789:46,23.37890625' ); |
23
|
|
|
|
24
|
|
|
$this->assertInstanceOf( Rectangle::class, $rectangle ); |
25
|
|
|
|
26
|
|
|
$expectedNorthEast = new LatLongValue( 51.8357775, 33.83789 ); |
27
|
|
|
$this->assertTrue( $expectedNorthEast->equals( $rectangle->getRectangleNorthEast() ) ); |
28
|
|
|
|
29
|
|
|
$expectedSouthWest = new LatLongValue( 46, 23.37890625 ); |
30
|
|
|
$this->assertTrue( $expectedSouthWest->equals( $rectangle->getRectangleSouthWest() ) ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testGivenTitleAndText_rectangleHasProvidedMetaData() { |
34
|
|
|
$parser = new RectangleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) ); |
35
|
|
|
|
36
|
|
|
$rectangle = $parser->parse( "51.8357775,33.83789:46,23.37890625~I'm a square~of doom" ); |
37
|
|
|
|
38
|
|
|
$this->assertInstanceOf( Rectangle::class, $rectangle ); |
39
|
|
|
|
40
|
|
|
$this->assertSame( "I'm a square", $rectangle->getTitle() ); |
41
|
|
|
$this->assertSame( 'of doom', $rectangle->getText() ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
} |
45
|
|
|
|