APIv4 - Remove implicit multi-joins
[civicrm-core.git] / tests / phpunit / api / v4 / Action / FkJoinTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 * $Id$
18 *
19 */
20
21
22 namespace api\v4\Action;
23
24 use api\v4\UnitTestCase;
25 use Civi\Api4\Activity;
26 use Civi\Api4\Contact;
27
28 /**
29 * @group headless
30 */
31 class FkJoinTest extends UnitTestCase {
32
33 public function setUpHeadless() {
34 $relatedTables = [
35 'civicrm_activity',
36 'civicrm_phone',
37 'civicrm_activity_contact',
38 ];
39 $this->cleanup(['tablesToTruncate' => $relatedTables]);
40 $this->loadDataSet('DefaultDataSet');
41
42 return parent::setUpHeadless();
43 }
44
45 /**
46 * Fetch all phone call activities. Expects a single activity
47 * loaded from the data set.
48 */
49 public function testThreeLevelJoin() {
50 $results = Activity::get()
51 ->setCheckPermissions(FALSE)
52 ->addWhere('activity_type_id:name', '=', 'Phone Call')
53 ->execute();
54
55 $this->assertCount(1, $results);
56 }
57
58 }