Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
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 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testCustomFieldsetTest() { | |
6a488035 | 35 | // Log in as admin first to verify permissions for CiviGrant |
42daf119 | 36 | $this->webtestLogin('admin'); |
6a488035 TO |
37 | |
38 | // Enable CiviGrant module if necessary | |
b9715b8a | 39 | $this->enableComponents("CiviGrant"); |
6a488035 TO |
40 | |
41 | // let's give full CiviGrant permissions to demo user (registered user). | |
42 | $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant'); | |
43 | $this->changePermissions($permission); | |
44 | ||
42daf119 CW |
45 | // Log in as normal user |
46 | $this->webtestLogin(); | |
47 | ||
6a488035 TO |
48 | // Create unique identifier for names |
49 | $rand = substr(sha1(rand()), 0, 7); | |
50 | ||
51 | // Add new Grant Type | |
118e964e | 52 | $this->openCiviPage('admin/options/grant_type', 'reset=1'); |
6a488035 TO |
53 | $this->click("css=#grant_type > div.action-link > #new > span"); |
54 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
55 | $grantType = 'GrantType' . $rand; | |
56 | $this->type('id=label', $grantType); | |
57 | $this->click('id=_qf_Options_next-top'); | |
58 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 59 | $this->waitForText('crm-notification-container', "The Grant Type '$grantType' has been saved."); |
6a488035 TO |
60 | |
61 | // Create new Custom Field Set that extends the grant type | |
79d6583c | 62 | $this->openCiviPage('admin/custom/group', 'reset=1'); |
6a488035 TO |
63 | $this->click("css=#newCustomDataGroup > span"); |
64 | $this->waitForElementPresent('_qf_Group_next-bottom'); | |
65 | $grantFieldSet = 'Fieldset' . $rand; | |
66 | $this->type('id=title', $grantFieldSet); | |
67 | $this->select('id=extends_0', 'label=Grants'); | |
68 | $this->addSelection('id=extends_1', "label=$grantType"); | |
69 | $this->click('id=collapse_display'); | |
70 | $this->click('id=_qf_Group_next-bottom'); | |
71 | $this->waitForElementPresent('_qf_Field_next-bottom'); | |
6c5f7368 | 72 | $this->waitForText('crm-notification-container', "Your custom field set '$grantFieldSet' has been added."); |
6a488035 TO |
73 | |
74 | // Add field to fieldset | |
75 | $grantField = 'GrantField' . $rand; | |
76 | $this->type('id=label', $grantField); | |
77 | $this->select('id=data_type_0', 'label=Money'); | |
78 | $this->click('id=_qf_Field_next-bottom'); | |
79 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 80 | $this->waitForText('crm-notification-container', "Your custom field '$grantField' has been saved."); |
6a488035 TO |
81 | |
82 | // Create new Grant | |
79d6583c | 83 | $this->openCiviPage('grant/add', 'reset=1&action=add&context=standalone', '_qf_Grant_upload-bottom'); |
6a488035 TO |
84 | $this->select('id=profiles_1', 'label=New Individual'); |
85 | $this->waitForElementPresent('_qf_Edit_next'); | |
86 | $firstName = 'First' . $rand; | |
87 | $lastName = 'Last' . $rand; | |
88 | $this->type('id=first_name', $firstName); | |
89 | $this->type('id=last_name', $lastName); | |
90 | $this->click('id=_qf_Edit_next'); | |
91 | $this->select('id=status_id', 'label=Approved'); | |
92 | $this->select('id=grant_type_id', "label=$grantType"); | |
93 | $this->waitForTextPresent($grantField); | |
79d6583c | 94 | $this->assertElementContainsText($grantFieldSet, $grantField); |
6a488035 TO |
95 | $this->type('id=amount_total', '100.00'); |
96 | $this->type("css=div#$grantFieldSet input.form-text", '99.99'); | |
225a8648 | 97 | $this->clickLink('id=_qf_Grant_upload-bottom', "xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 TO |
98 | |
99 | // Click through to the Grant view screen | |
100 | $this->click("xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); | |
101 | $this->waitForElementPresent('_qf_GrantView_cancel-bottom'); | |
102 | ||
103 | // verify tabular data for grant view | |
104 | $this->webtestVerifyTabularData(array( | |
105 | 'Name' => "$firstName $lastName", | |
106 | 'Grant Status' => 'Approved', | |
107 | 'Grant Type' => $grantType, | |
108 | $grantField => '$ 99.99', | |
109 | ) | |
110 | ); | |
111 | } | |
6a488035 | 112 | |
c4e6d4e8 PJ |
113 | function testAjaxCustomGroupLoad() { |
114 | $this->webtestLogin(); | |
115 | ||
116 | // Enable CiviGrant module if necessary | |
117 | $this->enableComponents("CiviGrant"); | |
118 | ||
119 | $triggerElement = array('name' => 'grant_type_id', 'type' => 'select'); | |
120 | $customSets = array( | |
121 | array('entity' => 'Grant', 'subEntity' => 'Emergency', 'triggerElement' => $triggerElement), | |
122 | array('entity' => 'Grant', 'subEntity' => 'Family Support', 'triggerElement' => $triggerElement) | |
123 | ); | |
124 | ||
125 | $pageUrl = array('url' => 'grant/add', 'args' => 'reset=1&action=add&context=standalone'); | |
126 | $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl); | |
127 | } | |
232624b1 | 128 | } |