Merge pull request #17981 from eileenmcnaughton/merge_form
[civicrm-core.git] / tests / phpunit / CRM / Contact / Form / Task / UseraddTest.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 /**
13 * @group headless
14 */
15 class CRM_Contact_Form_Task_UseraddTest extends CiviUnitTestCase {
16
17 /**
18 * Test postProcess failure.
19 *
20 * In unit tests, the CMS user creation will always fail, but that's
21 * ok because that's what we're testing here.
22 */
23 public function testUserCreateFail() {
24 $form = new CRM_Contact_Form_Task_Useradd();
25 // We don't need to set params or anything because we're testing fail,
26 // which the user creation will do in unit tests no matter what we set.
27 // But before the patch, the status messages were always success no
28 // matter what.
29 try {
30 $form->postProcess();
31 }
32 catch (CRM_Core_Exception_PrematureExitException $e) {
33 }
34 $statuses = CRM_Core_Session::singleton()->getStatus(TRUE);
35 $this->assertEquals('alert', $statuses[0]['type']);
36 }
37
38 }