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