AddressTest.php 1.4 KB

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