Commit | Line | Data |
---|---|---|
4715d267 | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7d61e75f | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
4715d267 | 5 | | | |
7d61e75f TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
4715d267 | 9 | +--------------------------------------------------------------------+ |
10 | */ | |
11 | /** | |
bc06f843 | 12 | * Test class for CRM_Mailing_Form_Task_AdhocMailing. |
4715d267 | 13 | * @group headless |
14 | */ | |
93287bd4 | 15 | class CRM_Mailing_Form_Task_AdhocMailingTest extends CiviUnitTestCase { |
4715d267 | 16 | |
93287bd4 | 17 | /** |
18 | * @throws \Exception | |
19 | */ | |
0b49aa04 | 20 | protected function setUp(): void { |
4715d267 | 21 | parent::setUp(); |
22 | $this->_contactIds = [ | |
23 | $this->individualCreate(['first_name' => 'Antonia', 'last_name' => 'D`souza']), | |
24 | $this->individualCreate(['first_name' => 'Anthony', 'last_name' => 'Collins']), | |
25 | ]; | |
93287bd4 | 26 | $this->_optionValue = $this->callAPISuccess('optionValue', 'create', [ |
4715d267 | 27 | 'label' => '"Seamus Lee" <seamus@example.com>', |
28 | 'option_group_id' => 'from_email_address', | |
29 | ]); | |
30 | } | |
31 | ||
32 | /** | |
33 | * Test creating a hidden smart group from a search builder search. | |
34 | * | |
35 | * A hidden smart group is a group used for sending emails. | |
36 | * | |
37 | * @throws \CRM_Core_Exception | |
38 | * @throws \Exception | |
39 | */ | |
40 | public function testCreateHiddenGroupFromSearchBuilder() { | |
41 | $this->createLoggedInUser(); | |
42 | $formValues = [ | |
4715d267 | 43 | 'entryURL' => 'http://dmaster.local/civicrm/contact/search/builder?reset=1', |
44 | 'mapper' => [1 => [['Individual']]], | |
45 | 'operator' => [1 => ['=']], | |
46 | 'value' => [1 => [0 => 'erwr']], | |
47 | '_qf_default' => 'Builder:refresh', | |
48 | '_qf_Builder_refresh' => 'Search', | |
49 | 'radio_ts' => '', | |
50 | ]; | |
51 | $form = $this->getFormObject('CRM_Mailing_Form_Task_AdhocMailing', $formValues, 'Builder'); | |
52 | $form->setAction(CRM_Core_Action::PROFILE); | |
93287bd4 | 53 | $form->set('formValues', $formValues); |
54 | $form->set('isSearchBuilder', 1); | |
55 | $form->set('context', 'builder'); | |
4715d267 | 56 | try { |
57 | $form->preProcess(); | |
58 | } | |
59 | catch (CRM_Core_Exception_PrematureExitException $e) { | |
60 | // Nothing to see here. | |
61 | } | |
62 | $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []); | |
93287bd4 | 63 | $this->assertEquals($formValues, $savedSearch['form_values']); |
4715d267 | 64 | } |
65 | ||
66 | } |