diff options
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OneToOneJoinTest.php')
-rw-r--r-- | www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OneToOneJoinTest.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OneToOneJoinTest.php b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OneToOneJoinTest.php new file mode 100644 index 00000000..ef05f657 --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OneToOneJoinTest.php @@ -0,0 +1,46 @@ +<?php + +namespace Civi\Test\Api4\Query; + +use Civi\Api4\Contact; +use Civi\Api4\OptionGroup; +use Civi\Api4\OptionValue; +use Civi\Test\Api4\UnitTestCase; + +/** + * Class OneToOneJoinTest + * @package Civi\Test\Api4\Query + * @group headless + */ +class OneToOneJoinTest extends UnitTestCase { + + public function testOneToOneJoin() { + $armenianContact = Contact::create() + ->addValue('first_name', 'Contact') + ->addValue('last_name', 'One') + ->addValue('contact_type', 'Individual') + ->addValue('preferred_language', 'hy_AM') + ->execute() + ->first(); + + $basqueContact = Contact::create() + ->addValue('first_name', 'Contact') + ->addValue('last_name', 'Two') + ->addValue('contact_type', 'Individual') + ->addValue('preferred_language', 'eu_ES') + ->execute() + ->first(); + + $contacts = Contact::get() + ->addWhere('id', 'IN', [$armenianContact['id'], $basqueContact['id']]) + ->addSelect('preferred_language.label') + ->addSelect('last_name') + ->execute() + ->indexBy('last_name') + ->getArrayCopy(); + + $this->assertEquals($contacts['One']['preferred_language']['label'], 'Armenian'); + $this->assertEquals($contacts['Two']['preferred_language']['label'], 'Basque'); + } + +} |