Merge pull request #17641 from MegaphoneJon/core-1590
[civicrm-core.git] / tests / phpunit / api / v3 / ClassAPITest.php
CommitLineData
36cf2d7e
AS
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12/**
13 * Test class for class.api.php
14 *
15 * @package CiviCRM_APIv3
16 * @group headless
17 */
18class class_api_test extends CiviUnitTestCase {
19
20 /**
21 * Test that error doesn't occur for non-existent file.
22 */
23 public function testConstructor() {
24 require_once 'api/class.api.php';
25
26 // Check no params is local
27 $api = new civicrm_api3();
28 $this->assertEquals(TRUE, $api->local);
29
30 // Be sure to include keys otherwise these calls die()
31 $keys = ['key' => 'my_site_key', 'api_key' => 'my_api_key'];
32
33 // Check empty server string is local
34 $api = new civicrm_api3(['server' => ''] + $keys);
35 $this->assertEquals(TRUE, $api->local);
36
37 // Check non-empty server string is remote, check default uri
38 $api = new civicrm_api3(['server' => 'http://my_server'] + $keys);
39 $this->assertEquals(FALSE, $api->local);
40 $this->assertEquals('http://my_server/sites/all/modules/civicrm/extern/rest.php', $api->uri);
41
42 // Check path in uri
43 $api = new civicrm_api3(['server' => 'http://my_server', 'path' => 'wibble'] + $keys);
44 $this->assertEquals('http://my_server/wibble', $api->uri);
45
46 }
47
48}