summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php')
-rw-r--r--www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php
new file mode 100644
index 00000000..75d4b977
--- /dev/null
+++ b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/tests/phpunit/Query/OptionValueJoinTest.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Civi\Test\Api4\Query;
+
+use Civi\Api4\Query\Api4SelectQuery;
+use Civi\Test\Api4\UnitTestCase;
+
+/**
+ * @group headless
+ */
+class OptionValueJoinTest extends UnitTestCase {
+
+ public function setUpHeadless() {
+ $relatedTables = [
+ 'civicrm_address',
+ 'civicrm_email',
+ 'civicrm_phone',
+ 'civicrm_openid',
+ 'civicrm_im',
+ 'civicrm_website',
+ 'civicrm_activity',
+ 'civicrm_activity_contact',
+ ];
+
+ $this->cleanup(['tablesToTruncate' => $relatedTables]);
+ $this->loadDataSet('SingleContact');
+
+ return parent::setUpHeadless();
+ }
+
+ public function testCommunicationMethodJoin() {
+ $query = new Api4SelectQuery('Contact', FALSE);
+ $query->select[] = 'first_name';
+ $query->select[] = 'preferred_communication_method.label';
+ $query->where[] = ['preferred_communication_method', 'IS NOT NULL'];
+ $results = $query->run();
+ $first = array_shift($results);
+ $firstPreferredMethod = array_shift($first['preferred_communication_method']);
+
+ $this->assertEquals(
+ 'Phone',
+ $firstPreferredMethod['label']
+ );
+ }
+
+}