-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBoundingBoxTest.php
80 lines (65 loc) · 2.29 KB
/
BoundingBoxTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* This file is part of the GeoJSON package.
*
* (c) Lorenzo Marzullo <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace GeoJSON\Tests;
use GeoJSON\BoundingBox;
use GeoJSON\Exception\InvalidArgumentException;
/**
* Class BoundingBoxTest.
*
* @package GeoJSON
* @author Lorenzo Marzullo <[email protected]>
* @link https://github.com/lorenzomar/geojson
*/
class BoundingBoxTest extends AbstractTestCase
{
public function testConstructNotNumericException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("BoundingBox values must be integers or floats");
new BoundingBox(['foo', 'bar', 'test', 10]);
}
public function testConstructInvalidMinValuesException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("BoundingBox requires at least four values");
new BoundingBox([-180, -90]);
}
public function testConstructInvalidOrderException()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage("BoundingBox min values must precede max values");
new BoundingBox([180, 90, -180, -90]);
}
public function testBoundsIntFloat()
{
$bounds = [-180, -90, 180.5, 90];
$bbox = new BoundingBox($bounds);
$this->assertSame($bounds, $bbox->bounds());
}
public function testBoundsNumeric()
{
$expected = [-180, -90, 180.5, 90.0];
$bounds = [-180, -90, "180.5", "90.0"];
$bbox = new BoundingBox($bounds);
$this->assertSame($expected, $bbox->bounds());
}
public function testEquals()
{
$bbox1 = new BoundingBox([-180, -90, 180.5, 90.0]);
$bbox2 = new BoundingBox([-180, -90, "180.5", 90.0]);
$bbox3 = new BoundingBox([-180, -90, 30, 90.0]);
$this->assertTrue($bbox1->equals($bbox2));
$this->assertTrue($bbox2->equals($bbox1));
$this->assertFalse($bbox1->equals($bbox3));
$this->assertFalse($bbox3->equals($bbox1));
$this->assertFalse($bbox2->equals($bbox3));
$this->assertFalse($bbox3->equals($bbox2));
}
}