Merge pull request #4069 from colemanw/confirm
[civicrm-core.git] / tests / phpunit / WebTest / Grant / ContactContextAddTest.php
CommitLineData
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 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Grant_ContactContextAddTest
31 */
6a488035
TO
32class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 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
45fabf8e 72 $this->waitForText('css=span.ui-dialog-title', "$firstName $lastName");
6a488035
TO
73
74 // check contact name on Grant form
6a488035 75
6a488035
TO
76 // select grant Status
77 $this->select('status_id', 'value=1');
78
79 // select grant type
80 $this->select('grant_type_id', 'value=1');
81
82 // total amount
83 $this->type('amount_total', '200');
84
85 // amount requested
86 $this->type('amount_requested', '200');
87
88 // amount granted
89 $this->type('amount_granted', '190');
90
91 // fill in application received Date
92 $this->webtestFillDate('application_received_date', 'now');
93
94 // fill in decision Date
95 $this->webtestFillDate('decision_date', 'now');
96
97 // fill in money transfered date
98 $this->webtestFillDate('money_transfer_date', 'now');
99
100 // fill in grant due Date
101 $this->webtestFillDate('grant_due_date', 'now');
102
103 // check grant report recieved.
104 $this->check('grant_report_received');
105
106 // grant rationale
107 $this->type('rationale', 'Grant Rationale for webtest');
108
109 // grant note
110 $this->type('note', "Grant Note for $firstName");
111
112 // Clicking save.
45fabf8e 113 $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
6a488035
TO
114
115 // click through to the Grant view screen
45fabf8e 116 $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE);
6a488035
TO
117
118 $gDate = date('F jS, Y', strtotime('now'));
119
120 // verify tabular data for grant view
121 $this->webtestVerifyTabularData(array(
122 'Name' => "$firstName $lastName",
123 'Grant Status' => 'Submitted',
124 'Grant Type' => 'Emergency',
125 'Application Received' => $gDate,
126 'Grant Decision' => $gDate,
127 'Money Transferred' => $gDate,
128 'Grant Report Due' => $gDate,
129 'Amount Requested' => '$ 200.00',
130 'Amount Granted' => '$ 190.00',
131 'Grant Report Received?' => 'Yes',
132 'Rationale' => 'Grant Rationale for webtest',
133 'Notes' => "Grant Note for $firstName",
134 )
135 );
136 }
137}
138