Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 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 | |
952cc48f WA |
64 | $this->click("xpath=//div[@class='crm-actions-ribbon']/ul[@id='actions']/li[@class='crm-contact-activity crm-summary-block']/div/a[@id='crm-contact-actions-link']"); |
65 | $this->waitForElementPresent('crm-contact-actions-list'); | |
6a488035 TO |
66 | |
67 | // wait for add Grant link | |
68 | $this->waitForElementPresent('link=Add Grant'); | |
69 | ||
70 | $this->click('link=Add Grant'); | |
71 | ||
72 | // wait for grant form to load completely | |
bf333c47 JP |
73 | $this->waitForText('css=span.ui-dialog-title', "New Grant"); |
74 | $this->waitForElementPresent('status_id'); | |
6a488035 TO |
75 | |
76 | // check contact name on Grant form | |
6a488035 | 77 | |
6a488035 TO |
78 | // select grant Status |
79 | $this->select('status_id', 'value=1'); | |
80 | ||
81 | // select grant type | |
82 | $this->select('grant_type_id', 'value=1'); | |
83 | ||
84 | // total amount | |
85 | $this->type('amount_total', '200'); | |
86 | ||
87 | // amount requested | |
88 | $this->type('amount_requested', '200'); | |
89 | ||
90 | // amount granted | |
91 | $this->type('amount_granted', '190'); | |
92 | ||
93 | // fill in application received Date | |
94 | $this->webtestFillDate('application_received_date', 'now'); | |
95 | ||
96 | // fill in decision Date | |
97 | $this->webtestFillDate('decision_date', 'now'); | |
98 | ||
e4f46be0 | 99 | // fill in money transferred date |
6a488035 TO |
100 | $this->webtestFillDate('money_transfer_date', 'now'); |
101 | ||
102 | // fill in grant due Date | |
103 | $this->webtestFillDate('grant_due_date', 'now'); | |
104 | ||
e4f46be0 | 105 | // check grant report received. |
6a488035 TO |
106 | $this->check('grant_report_received'); |
107 | ||
108 | // grant rationale | |
109 | $this->type('rationale', 'Grant Rationale for webtest'); | |
110 | ||
111 | // grant note | |
112 | $this->type('note', "Grant Note for $firstName"); | |
113 | ||
114 | // Clicking save. | |
45fabf8e | 115 | $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); |
6a488035 TO |
116 | |
117 | // click through to the Grant view screen | |
45fabf8e | 118 | $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE); |
6a488035 TO |
119 | |
120 | $gDate = date('F jS, Y', strtotime('now')); | |
121 | ||
122 | // verify tabular data for grant view | |
123 | $this->webtestVerifyTabularData(array( | |
124 | 'Name' => "$firstName $lastName", | |
125 | 'Grant Status' => 'Submitted', | |
126 | 'Grant Type' => 'Emergency', | |
127 | 'Application Received' => $gDate, | |
128 | 'Grant Decision' => $gDate, | |
129 | 'Money Transferred' => $gDate, | |
130 | 'Grant Report Due' => $gDate, | |
131 | 'Amount Requested' => '$ 200.00', | |
132 | 'Amount Granted' => '$ 190.00', | |
133 | 'Grant Report Received?' => 'Yes', | |
134 | 'Rationale' => 'Grant Rationale for webtest', | |
135 | 'Notes' => "Grant Note for $firstName", | |
136 | ) | |
137 | ); | |
138 | } | |
96025800 | 139 | |
6a488035 | 140 | } |