3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
12 * Test class for CRM_Contact_Form_Task_EmailCommon.
15 class CRM_Mailing_Form_Task_AdhocMailingTest
extends CiviUnitTestCase
{
20 protected function setUp() {
22 $this->_contactIds
= [
23 $this->individualCreate(['first_name' => 'Antonia', 'last_name' => 'D`souza']),
24 $this->individualCreate(['first_name' => 'Anthony', 'last_name' => 'Collins']),
26 $this->_optionValue
= $this->callAPISuccess('optionValue', 'create', [
27 'label' => '"Seamus Lee" <seamus@example.com>',
28 'option_group_id' => 'from_email_address',
33 * Test creating a hidden smart group from a search builder search.
35 * A hidden smart group is a group used for sending emails.
37 * @throws \CRM_Core_Exception
40 public function testCreateHiddenGroupFromSearchBuilder() {
41 $this->createLoggedInUser();
43 'qfKey' => 'dde96a85ddebb90fb66de44859404aeb_2077',
44 'entryURL' => 'http://dmaster.local/civicrm/contact/search/builder?reset=1',
45 'mapper' => [1 => [['Individual']]],
46 'operator' => [1 => ['=']],
47 'value' => [1 => [0 => 'erwr']],
48 '_qf_default' => 'Builder:refresh',
49 '_qf_Builder_refresh' => 'Search',
52 $form = $this->getFormObject('CRM_Mailing_Form_Task_AdhocMailing', $formValues, 'Builder');
53 $form->setAction(CRM_Core_Action
::PROFILE
);
54 $form->set('formValues', $formValues);
55 $form->set('isSearchBuilder', 1);
56 $form->set('context', 'builder');
60 catch (CRM_Core_Exception_PrematureExitException
$e) {
61 // Nothing to see here.
63 $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
64 $this->assertEquals($formValues, $savedSearch['form_values']);