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\Query
;
22 use Civi\Api4\Contact
;
23 use api\v
4\Api4TestBase
;
24 use Civi\Test\TransactionalInterface
;
27 * Class OneToOneJoinTest
28 * @package api\v4\Query
31 class OneToOneJoinTest
extends Api4TestBase
implements TransactionalInterface
{
33 public function testOneToOneJoin() {
34 $armenianContact = Contact
::create()
35 ->addValue('first_name', 'Contact')
36 ->addValue('last_name', 'One')
37 ->addValue('contact_type', 'Individual')
38 ->addValue('preferred_language', 'hy_AM')
42 $basqueContact = Contact
::create()
43 ->addValue('first_name', 'Contact')
44 ->addValue('last_name', 'Two')
45 ->addValue('contact_type', 'Individual')
46 ->addValue('preferred_language', 'eu_ES')
50 $contacts = Contact
::get()
51 ->addWhere('id', 'IN', [$armenianContact['id'], $basqueContact['id']])
52 ->addSelect('preferred_language:label')
53 ->addSelect('last_name')
55 ->indexBy('last_name');
57 $this->assertEquals($contacts['One']['preferred_language:label'], 'Armenian');
58 $this->assertEquals($contacts['Two']['preferred_language:label'], 'Basque');