| 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 ability to join across multiple entities |
| 14 | * |
| 15 | * @package CiviCRM_APIv3 |
| 16 | * @group headless |
| 17 | */ |
| 18 | class api_v3_EntityJoinTest extends CiviUnitTestCase { |
| 19 | |
| 20 | public function setUp() { |
| 21 | parent::setUp(); |
| 22 | $this->useTransaction(TRUE); |
| 23 | } |
| 24 | |
| 25 | public function testJoinEmailToContact() { |
| 26 | $first = 'firstthisisatest'; |
| 27 | $last = 'lastthisisatest'; |
| 28 | $org = $this->organizationCreate(['organization_name' => 'Employer of one']); |
| 29 | $person1 = $this->individualCreate(['employer_id' => $org, 'first_name' => $first, 'last_name' => $last, 'gender_id' => 1]); |
| 30 | $person2 = $this->individualCreate([], 1); |
| 31 | $result = $this->callAPISuccessGetSingle('Email', [ |
| 32 | 'return' => 'contact_id.employer_id.display_name,contact_id.gender_id.label', |
| 33 | 'contact_id.last_name' => $last, |
| 34 | 'contact_id.first_name' => $first, |
| 35 | ]); |
| 36 | $this->assertEquals('Employer of one', $result['contact_id.employer_id.display_name']); |
| 37 | $this->assertEquals('Female', $result['contact_id.gender_id.label']); |
| 38 | } |
| 39 | |
| 40 | } |