4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace api\v
4\Action
;
22 use api\v
4\Api4TestBase
;
23 use Civi\Api4\Address
;
24 use Civi\Test\TransactionalInterface
;
29 class AddressGetCoordinatesTest
extends Api4TestBase
implements TransactionalInterface
{
31 public function setUp(): void
{
33 \Civi\Api4\Setting
::set()
34 ->addValue('geoProvider', 'TestProvider')
38 public function tearDown(): void
{
40 \Civi\Api4\Setting
::revert()
41 ->addSelect('geoProvider')
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']);
51 public function testGetCoordinatesNoAddress(): void
{
52 $coorindates = Address
::getCoordinates()->setAddress('Does not exist, Washington, DC, USA')->execute()->first();
53 $this->assertEmpty($coorindates);