|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Geocoder package. |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* @license MIT License |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Geocoder\Plugin\Tests\Plugin; |
|
14
|
|
|
|
|
15
|
|
|
use Geocoder\Model\Bounds; |
|
16
|
|
|
use Geocoder\Plugin\Plugin\BoundsPlugin; |
|
17
|
|
|
use Geocoder\Query\GeocodeQuery; |
|
18
|
|
|
use Geocoder\Query\Query; |
|
19
|
|
|
use Geocoder\Query\ReverseQuery; |
|
20
|
|
|
use PHPUnit\Framework\TestCase; |
|
21
|
|
|
|
|
22
|
|
|
class BoundsPluginTest extends TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
public function testGeocode() |
|
25
|
|
|
{ |
|
26
|
|
|
$bounds = new Bounds(4, 7, 1, 1); |
|
27
|
|
|
$query = GeocodeQuery::create('foo'); |
|
28
|
|
|
$first = function (Query $query) { |
|
29
|
|
|
$this->fail('Plugin should not restart the chain'); |
|
30
|
|
|
}; |
|
31
|
|
|
$next = function (GeocodeQuery $query) use ($bounds) { |
|
32
|
|
|
$this->assertEquals($bounds, $query->getBounds()); |
|
33
|
|
|
}; |
|
34
|
|
|
|
|
35
|
|
|
$plugin = new BoundsPlugin($bounds); |
|
36
|
|
|
$plugin->handleQuery($query, $next, $first); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testReverse() |
|
40
|
|
|
{ |
|
41
|
|
|
$bounds = new Bounds(4, 7, 1, 1); |
|
42
|
|
|
$query = ReverseQuery::fromCoordinates(71, 11); |
|
43
|
|
|
$first = function (Query $query) { |
|
44
|
|
|
$this->fail('Plugin should not restart the chain'); |
|
45
|
|
|
}; |
|
46
|
|
|
$next = function (Query $query) use ($bounds) { |
|
47
|
|
|
$this->assertTrue(true, 'We should not fail on ReverseQuery'); |
|
48
|
|
|
}; |
|
49
|
|
|
|
|
50
|
|
|
$plugin = new BoundsPlugin($bounds); |
|
51
|
|
|
$plugin->handleQuery($query, $next, $first); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|