Merge pull request #11241 from mattwire/CRM-21392_find_groups_viewcomponents
[civicrm-core.git] / tests / phpunit / WebTest / Grant / ContactContextAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Grant_ContactContextAddTest
31 */
32 class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testContactContextAddTest() {
39 // Log in as admin first to verify permissions for CiviGrant
40 $this->webtestLogin('admin');
41
42 // Enable CiviGrant module if necessary
43 $this->enableComponents("CiviGrant");
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
49 // Log in as normal user
50 $this->webtestLogin();
51
52 // create unique name
53 $name = substr(sha1(rand()), 0, 7);
54 $firstName = 'Grant' . $name;
55 $lastName = 'L' . $name;
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("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');
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
73 $this->waitForText('css=span.ui-dialog-title', "New Grant");
74 $this->waitForElementPresent('status_id');
75
76 // check contact name on Grant form
77
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
99 // fill in money transferred date
100 $this->webtestFillDate('money_transfer_date', 'now');
101
102 // fill in grant due Date
103 $this->webtestFillDate('grant_due_date', 'now');
104
105 // check grant report received.
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.
115 $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
116
117 // click through to the Grant view screen
118 $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE);
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 }
139
140 }