-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP][NFC] dev/mail#103 Add in unit test to demonstate issue with API…
…v4 and joins
- Loading branch information
1 parent
016e9d5
commit c555a17
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
/** | ||
* | ||
* @package CRM | ||
* @copyright CiviCRM LLC https://civicrm.org/licensing | ||
*/ | ||
|
||
|
||
namespace api\v4\Entity; | ||
|
||
use Civi\Api4\Contact; | ||
use Civi\Api4\CustomGroup; | ||
use Civi\Api4\CustomField; | ||
use api\v4\UnitTestCase; | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class ContactCustomJoinTest extends UnitTestCase { | ||
|
||
public function testContactCustomJoin() { | ||
$customGroup = CustomGroup::create()->setValues([ | ||
'name' => 'D - Identification_20', | ||
'table_name' => 'civicrm_value_demographics', | ||
'title' => 'D - Identification', | ||
'extends' => 'Individual', | ||
])->execute(); | ||
\CRM_Core_DAO::executeQuery("UPDATE civicrm_custom_group SET name = 'D - Identification_20' WHERE id = %1", [1 => [$customGroup[0]['id'], 'Integer']]); | ||
$customField = CustomField::create()->setValues([ | ||
'label' => 'Test field', | ||
'custom_group_id' => $customGroup[0]['id'], | ||
'html_type' => 'Text', | ||
'data_type' => 'String', | ||
])->execute(); | ||
Contact::get()->addSelect('*')->addSelect('custom.*')->execute(); | ||
CustomField::delete()->addWhere('id', '=', $customField[0]['id']); | ||
CustomGroup::delete()->addWhere('id', '=', $customGroup[0]['id']); | ||
} | ||
|
||
} |