AddressTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Generator;
  4. use Faker\Provider\Address;
  5. use PHPUnit\Framework\TestCase;
  6. class AddressTest extends TestCase
  7. {
  8. private $faker;
  9. public function setUp()
  10. {
  11. $faker = new Generator();
  12. $faker->addProvider(new Address($faker));
  13. $this->faker = $faker;
  14. }
  15. public function testLatitude()
  16. {
  17. $latitude = $this->faker->latitude();
  18. $this->assertInternalType('float', $latitude);
  19. $this->assertGreaterThanOrEqual(-90, $latitude);
  20. $this->assertLessThanOrEqual(90, $latitude);
  21. }
  22. public function testLongitude()
  23. {
  24. $longitude = $this->faker->longitude();
  25. $this->assertInternalType('float', $longitude);
  26. $this->assertGreaterThanOrEqual(-180, $longitude);
  27. $this->assertLessThanOrEqual(180, $longitude);
  28. }
  29. public function testCoordinate()
  30. {
  31. $coordinate = $this->faker->localCoordinates();
  32. $this->assertInternalType('array', $coordinate);
  33. $this->assertInternalType('float', $coordinate['latitude']);
  34. $this->assertGreaterThanOrEqual(-90, $coordinate['latitude']);
  35. $this->assertLessThanOrEqual(90, $coordinate['latitude']);
  36. $this->assertInternalType('float', $coordinate['longitude']);
  37. $this->assertGreaterThanOrEqual(-180, $coordinate['longitude']);
  38. $this->assertLessThanOrEqual(180, $coordinate['longitude']);
  39. }
  40. }