Merge pull request #23283 from eileenmcnaughton/import_saved_map
[civicrm-core.git] / tests / phpunit / api / v4 / Action / AddressGetCoordinatesTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19
20 namespace api\v4\Action;
21
22 use api\v4\Api4TestBase;
23 use Civi\Api4\Address;
24 use Civi\Test\TransactionalInterface;
25
26 /**
27 * @group headless
28 */
29 class AddressGetCoordinatesTest extends Api4TestBase implements TransactionalInterface {
30
31 public function setUp(): void {
32 parent::setUp();
33 \Civi\Api4\Setting::set()
34 ->addValue('geoProvider', 'TestProvider')
35 ->execute();
36 }
37
38 public function tearDown(): void {
39 parent::tearDown();
40 \Civi\Api4\Setting::revert()
41 ->addSelect('geoProvider')
42 ->execute();
43 }
44
45 public function testGetCoordinatesWhiteHouse(): void {
46 $coordinates = Address::getCoordinates()->setAddress('600 Pennsylvania Avenue NW, Washington, DC, USA')->execute()->first();
47 $this->assertEquals('38.897957', $coordinates['geo_code_1']);
48 $this->assertEquals('-77.036560', $coordinates['geo_code_2']);
49 }
50
51 public function testGetCoordinatesNoAddress(): void {
52 $coorindates = Address::getCoordinates()->setAddress('Does not exist, Washington, DC, USA')->execute()->first();
53 $this->assertEmpty($coorindates);
54 }
55
56 }