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\Circle; |
9
|
|
|
use Maps\Presentation\WikitextParsers\CircleParser; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \Maps\Presentation\WikitextParsers\CircleParser |
14
|
|
|
* @licence GNU GPL v2+ |
15
|
|
|
* @author Jeroen De Dauw < [email protected] > |
16
|
|
|
*/ |
17
|
|
|
class CircleParserTest extends TestCase { |
18
|
|
|
|
19
|
|
|
public function testGivenCoordinateAndRadius_parserReturnsCircle() { |
20
|
|
|
$parser = new CircleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) ); |
21
|
|
|
|
22
|
|
|
$circle = $parser->parse( '57.421,23.90625:32684.605182' ); |
23
|
|
|
|
24
|
|
|
$this->assertInstanceOf( Circle::class, $circle ); |
25
|
|
|
|
26
|
|
|
$expectedLatLong = new LatLongValue( 57.421, 23.90625 ); |
27
|
|
|
$this->assertTrue( $expectedLatLong->equals( $circle->getCircleCentre() ) ); |
28
|
|
|
|
29
|
|
|
$this->assertSame( 32684.605182, $circle->getCircleRadius() ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGivenTitleAndText_circleHasProvidedMetaData() { |
33
|
|
|
$parser = new CircleParser( new CoordinateFriendlyGeocoder( new NullGeocoder() ) ); |
34
|
|
|
|
35
|
|
|
$circle = $parser->parse( '57.421,23.90625:32684.605182~title~text' ); |
36
|
|
|
|
37
|
|
|
$this->assertInstanceOf( Circle::class, $circle ); |
38
|
|
|
|
39
|
|
|
$this->assertSame( 'title', $circle->getTitle() ); |
40
|
|
|
$this->assertSame( 'text', $circle->getText() ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
} |
44
|
|
|
|