Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
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 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testContactContextAddTest() { | |
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 | 48 | // create unique name |
42daf119 | 49 | $name = substr(sha1(rand()), 0, 7); |
6a488035 | 50 | $firstName = 'Grant' . $name; |
42daf119 | 51 | $lastName = 'L' . $name; |
6a488035 TO |
52 | |
53 | // create new contact | |
54 | $this->webtestAddContact($firstName, $lastName); | |
55 | ||
56 | // wait for action element | |
57 | $this->waitForElementPresent('crm-contact-actions-link'); | |
58 | ||
59 | // now add grant from contact summary | |
60 | $this->click("//a[@id='crm-contact-actions-link']/span/div"); | |
61 | ||
62 | // wait for add Grant link | |
63 | $this->waitForElementPresent('link=Add Grant'); | |
64 | ||
65 | $this->click('link=Add Grant'); | |
66 | ||
67 | // wait for grant form to load completely | |
68 | $this->waitForElementPresent('note'); | |
69 | ||
70 | // check contact name on Grant form | |
79d6583c | 71 | $this->assertElementContainsText('page-title', "$firstName $lastName"); |
6a488035 | 72 | |
6a488035 TO |
73 | // select grant Status |
74 | $this->select('status_id', 'value=1'); | |
75 | ||
76 | // select grant type | |
77 | $this->select('grant_type_id', 'value=1'); | |
78 | ||
79 | // total amount | |
80 | $this->type('amount_total', '200'); | |
81 | ||
82 | // amount requested | |
83 | $this->type('amount_requested', '200'); | |
84 | ||
85 | // amount granted | |
86 | $this->type('amount_granted', '190'); | |
87 | ||
88 | // fill in application received Date | |
89 | $this->webtestFillDate('application_received_date', 'now'); | |
90 | ||
91 | // fill in decision Date | |
92 | $this->webtestFillDate('decision_date', 'now'); | |
93 | ||
94 | // fill in money transfered date | |
95 | $this->webtestFillDate('money_transfer_date', 'now'); | |
96 | ||
97 | // fill in grant due Date | |
98 | $this->webtestFillDate('grant_due_date', 'now'); | |
99 | ||
100 | // check grant report recieved. | |
101 | $this->check('grant_report_received'); | |
102 | ||
103 | // grant rationale | |
104 | $this->type('rationale', 'Grant Rationale for webtest'); | |
105 | ||
106 | // grant note | |
107 | $this->type('note', "Grant Note for $firstName"); | |
108 | ||
109 | // Clicking save. | |
225a8648 | 110 | $this->clickLink('_qf_Grant_upload', "xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 TO |
111 | |
112 | // click through to the Grant view screen | |
225a8648 | 113 | $this->clickLink("xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom'); |
6a488035 TO |
114 | |
115 | $gDate = date('F jS, Y', strtotime('now')); | |
116 | ||
117 | // verify tabular data for grant view | |
118 | $this->webtestVerifyTabularData(array( | |
119 | 'Name' => "$firstName $lastName", | |
120 | 'Grant Status' => 'Submitted', | |
121 | 'Grant Type' => 'Emergency', | |
122 | 'Application Received' => $gDate, | |
123 | 'Grant Decision' => $gDate, | |
124 | 'Money Transferred' => $gDate, | |
125 | 'Grant Report Due' => $gDate, | |
126 | 'Amount Requested' => '$ 200.00', | |
127 | 'Amount Granted' => '$ 190.00', | |
128 | 'Grant Report Received?' => 'Yes', | |
129 | 'Rationale' => 'Grant Rationale for webtest', | |
130 | 'Notes' => "Grant Note for $firstName", | |
131 | ) | |
132 | ); | |
133 | } | |
134 | } | |
135 |