Rename test clas to reflect tested class name
[civicrm-core.git] / tests / phpunit / CRM / Mailing / Form / Task / AdhocMailingTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11 /**
12 * Test class for CRM_Mailing_Form_Task_AdhocMailing.
13 * @group headless
14 */
15 class CRM_Mailing_Form_Task_AdhocMailingTest extends CiviUnitTestCase {
16
17 /**
18 * @throws \Exception
19 */
20 protected function setUp(): void {
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 ];
26 $this->_optionValue = $this->callAPISuccess('optionValue', 'create', [
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 = [
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);
53 $form->set('formValues', $formValues);
54 $form->set('isSearchBuilder', 1);
55 $form->set('context', 'builder');
56 try {
57 $form->preProcess();
58 }
59 catch (CRM_Core_Exception_PrematureExitException $e) {
60 // Nothing to see here.
61 }
62 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
63 $this->assertEquals($formValues, $savedSearch['form_values']);
64 }
65
66 }