Merge pull request #17294 from agh1/sr-rel-perms
[civicrm-core.git] / tests / phpunit / api / v3 / UserTest.php
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 APIv3 civicrm_user_* functions
14 *
15 * @package CiviCRM_APIv3
16 * @subpackage API_Contact
17 * @group headless
18 */
19 class api_v3_UserTest extends CiviUnitTestCase {
20 protected $_apiversion = 3;
21 protected $params;
22 protected $_entity = 'User';
23 protected $contactID;
24
25 public $DBResetRequired = FALSE;
26
27 public function setUp() {
28 parent::setUp();
29 $this->contactID = $this->createLoggedInUser();
30 $this->params = [
31 'contact_id' => $this->contactID,
32 'sequential' => 1,
33 ];
34 }
35
36 public function testUserGet() {
37 $result = $this->callAPIAndDocument($this->_entity, 'get', $this->params, __FUNCTION__, __FILE__);
38 $this->assertEquals(1, $result['count']);
39 $this->assertEquals($this->contactID, $result['values'][0]['contact_id']);
40 $this->assertEquals(6, $result['values'][0]['id']);
41 $this->assertEquals('superman', $result['values'][0]['name']);
42 }
43
44 /**
45 * Test retrieval of label metadata.
46 */
47 public function testGetFields() {
48 $result = $this->callAPIAndDocument($this->_entity, 'getfields', ['action' => 'get'], __FUNCTION__, __FILE__);
49 $this->assertArrayKeyExists('name', $result['values']);
50 }
51
52 }