Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Grant_ContactContextAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testContactContextAddTest() { |
6a488035 | 39 | // Log in as admin first to verify permissions for CiviGrant |
42daf119 | 40 | $this->webtestLogin('admin'); |
6a488035 TO |
41 | |
42 | // Enable CiviGrant module if necessary | |
b9715b8a | 43 | $this->enableComponents("CiviGrant"); |
6a488035 TO |
44 | |
45 | // let's give full CiviGrant permissions to demo user (registered user). | |
46 | $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant'); | |
47 | $this->changePermissions($permission); | |
48 | ||
42daf119 CW |
49 | // Log in as normal user |
50 | $this->webtestLogin(); | |
51 | ||
6a488035 | 52 | // create unique name |
42daf119 | 53 | $name = substr(sha1(rand()), 0, 7); |
6a488035 | 54 | $firstName = 'Grant' . $name; |
42daf119 | 55 | $lastName = 'L' . $name; |
6a488035 TO |
56 | |
57 | // create new contact | |
58 | $this->webtestAddContact($firstName, $lastName); | |
59 | ||
60 | // wait for action element | |
61 | $this->waitForElementPresent('crm-contact-actions-link'); | |
62 | ||
63 | // now add grant from contact summary | |
64 | $this->click("//a[@id='crm-contact-actions-link']/span/div"); | |
65 | ||
66 | // wait for add Grant link | |
67 | $this->waitForElementPresent('link=Add Grant'); | |
68 | ||
69 | $this->click('link=Add Grant'); | |
70 | ||
71 | // wait for grant form to load completely | |
bf333c47 JP |
72 | $this->waitForText('css=span.ui-dialog-title', "New Grant"); |
73 | $this->waitForElementPresent('status_id'); | |
6a488035 TO |
74 | |
75 | // check contact name on Grant form | |
6a488035 | 76 | |
6a488035 TO |
77 | // select grant Status |
78 | $this->select('status_id', 'value=1'); | |
79 | ||
80 | // select grant type | |
81 | $this->select('grant_type_id', 'value=1'); | |
82 | ||
83 | // total amount | |
84 | $this->type('amount_total', '200'); | |
85 | ||
86 | // amount requested | |
87 | $this->type('amount_requested', '200'); | |
88 | ||
89 | // amount granted | |
90 | $this->type('amount_granted', '190'); | |
91 | ||
92 | // fill in application received Date | |
93 | $this->webtestFillDate('application_received_date', 'now'); | |
94 | ||
95 | // fill in decision Date | |
96 | $this->webtestFillDate('decision_date', 'now'); | |
97 | ||
98 | // fill in money transfered date | |
99 | $this->webtestFillDate('money_transfer_date', 'now'); | |
100 | ||
101 | // fill in grant due Date | |
102 | $this->webtestFillDate('grant_due_date', 'now'); | |
103 | ||
104 | // check grant report recieved. | |
105 | $this->check('grant_report_received'); | |
106 | ||
107 | // grant rationale | |
108 | $this->type('rationale', 'Grant Rationale for webtest'); | |
109 | ||
110 | // grant note | |
111 | $this->type('note', "Grant Note for $firstName"); | |
112 | ||
113 | // Clicking save. | |
45fabf8e | 114 | $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); |
6a488035 TO |
115 | |
116 | // click through to the Grant view screen | |
45fabf8e | 117 | $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE); |
6a488035 TO |
118 | |
119 | $gDate = date('F jS, Y', strtotime('now')); | |
120 | ||
121 | // verify tabular data for grant view | |
122 | $this->webtestVerifyTabularData(array( | |
123 | 'Name' => "$firstName $lastName", | |
124 | 'Grant Status' => 'Submitted', | |
125 | 'Grant Type' => 'Emergency', | |
126 | 'Application Received' => $gDate, | |
127 | 'Grant Decision' => $gDate, | |
128 | 'Money Transferred' => $gDate, | |
129 | 'Grant Report Due' => $gDate, | |
130 | 'Amount Requested' => '$ 200.00', | |
131 | 'Amount Granted' => '$ 190.00', | |
132 | 'Grant Report Received?' => 'Yes', | |
133 | 'Rationale' => 'Grant Rationale for webtest', | |
134 | 'Notes' => "Grant Note for $firstName", | |
135 | ) | |
136 | ); | |
137 | } | |
138 | } |