|
| 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\Provider\Faker\Tests; |
| 14 | + |
| 15 | +use Geocoder\IntegrationTest\BaseTestCase; |
| 16 | +use Geocoder\Model\Address; |
| 17 | +use Geocoder\Provider\Faker\Faker; |
| 18 | +use Geocoder\Query\GeocodeQuery; |
| 19 | +use Geocoder\Query\ReverseQuery; |
| 20 | + |
| 21 | +class FakerTest extends BaseTestCase |
| 22 | +{ |
| 23 | + protected function getCacheDir(): string |
| 24 | + { |
| 25 | + return __DIR__.'/.cached_responses'; |
| 26 | + } |
| 27 | + |
| 28 | + public function testGetName(): void |
| 29 | + { |
| 30 | + $provider = new Faker(); |
| 31 | + |
| 32 | + $this->assertEquals('faker', $provider->getName()); |
| 33 | + } |
| 34 | + |
| 35 | + public function testGeocode(): void |
| 36 | + { |
| 37 | + $provider = new Faker(); |
| 38 | + $result = $provider->geocodeQuery(GeocodeQuery::create('Dummy address')); |
| 39 | + |
| 40 | + $this->assertContainsOnlyInstancesOf(Address::class, $result); |
| 41 | + $this->assertCount(5, $result); |
| 42 | + } |
| 43 | + |
| 44 | + public function testReverse(): void |
| 45 | + { |
| 46 | + $provider = new Faker(); |
| 47 | + $result = $provider->reverseQuery(ReverseQuery::fromCoordinates(48.86, 2.35)); |
| 48 | + |
| 49 | + $this->assertContainsOnlyInstancesOf(Address::class, $result); |
| 50 | + $this->assertCount(5, $result); |
| 51 | + } |
| 52 | + |
| 53 | + public function testQueryWithLimit(): void |
| 54 | + { |
| 55 | + $provider = new Faker(); |
| 56 | + $result = $provider->geocodeQuery(GeocodeQuery::create('Dummy address')->withLimit(10)); |
| 57 | + |
| 58 | + $this->assertContainsOnlyInstancesOf(Address::class, $result); |
| 59 | + $this->assertCount(10, $result); |
| 60 | + } |
| 61 | +} |
0 commit comments