|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the BazingaGeocoderBundle 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 Bazinga\GeocoderBundle\Tests\Plugin; |
| 14 | + |
| 15 | +use Bazinga\GeocoderBundle\Plugin\FakeIpPlugin; |
| 16 | +use Geocoder\Query\GeocodeQuery; |
| 17 | +use Geocoder\Query\Query; |
| 18 | +use PHPUnit\Framework\TestCase; |
| 19 | + |
| 20 | +/** |
| 21 | + * @author Quentin Dequippe <quentin@dequippe.tech |
| 22 | + */ |
| 23 | +class FakeIpPluginTest extends TestCase |
| 24 | +{ |
| 25 | + public function testSimpleHandleQuery() |
| 26 | + { |
| 27 | + $fakeIpPlugin = new FakeIpPlugin('127.0.0.1', '123.123.123.123'); |
| 28 | + $query = GeocodeQuery::create('127.0.0.1'); |
| 29 | + |
| 30 | + /** @var Query $query */ |
| 31 | + $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); |
| 32 | + |
| 33 | + $this->assertSame($query->getText(), '123.123.123.123'); |
| 34 | + } |
| 35 | + |
| 36 | + public function testHandleQueryUsingFaker() |
| 37 | + { |
| 38 | + $fakeIpPlugin = new FakeIpPlugin('127.0.0.1', '192.168.1.1', true); |
| 39 | + $query = GeocodeQuery::create('127.0.0.1'); |
| 40 | + |
| 41 | + /** @var Query $query */ |
| 42 | + $query = $fakeIpPlugin->handleQuery($query, function (Query $query) { return $query; }, function () {}); |
| 43 | + |
| 44 | + $this->assertNotSame($query->getText(), '192.168.1.1'); |
| 45 | + } |
| 46 | +} |
0 commit comments