Import from SVN (r45945, r596)
[civicrm-core.git] / tests / phpunit / WebTest / ACL / AssignUsersToRolesTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testAssignUsersToRoles() {
36 $this->open($this->sboxPath);
37
38 $this->webtestLogin();
39 // Go directly to the URL of the screen that will create new group.
40 $this->open($this->sboxPath . "civicrm/group/add?reset=1");
41 $groupTitle = "testGroup" . substr(sha1(rand()), 0, 4);
42 $this->type("title", $groupTitle);
43 $this->click("group_type[1]");
44 $this->click("_qf_Edit_upload-bottom");
45 $this->waitForPageToLoad($this->getTimeoutMsec());
46
47 $this->assertTrue($this->isTextPresent("The Group '{$groupTitle}' has been saved."));
48
49 // Go directly to the URL that will create a new ACL role
50 $this->open($this->sboxPath . "civicrm/admin/options/acl_role?group=acl_role&action=add&reset=1");
51
52 $this->waitForElementPresent("_qf_Options_cancel-bottom");
53
54 $label = "TestAclRole" . substr(sha1(rand()), 0, 4);
55 $this->type("label", $label);
56 $this->click("_qf_Options_next-bottom");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
58 $this->assertTrue($this->isTextPresent("The Acl Role '{$label}' has been saved "));
59
60
61 // Go directly to the URL of the screen that will assign users to role.
62 $this->open($this->sboxPath . "civicrm/acl/entityrole?action=add&reset=1");
63
64 $this->select("acl_role_id", "label=" . $label);
65 $this->select("entity_id", "label={$groupTitle}");
66
67 $this->click("_qf_EntityRole_next-botttom");
68 $this->waitForPageToLoad($this->getTimeoutMsec());
69
70
71 // Go directly to the URL of the screen that will manage ACLs
72 $this->open($this->sboxPath . "civicrm/acl?action=add&reset=1");
73 $this->click("group_id");
74 $this->select("group_id", "label={$groupTitle}");
75 $this->select("operation", "label=View");
76 $this->select("entity_id", "label={$label}");
77 $this->type("name", "describe {$label}");
78 $this->click("_qf_ACL_next-bottom");
79 $this->waitForPageToLoad($this->getTimeoutMsec());
80 }
81 }
82