Merge pull request #4772 from jitendrapurohit/CRM-15750
[civicrm-core.git] / tests / phpunit / WebTest / Grant / StandaloneAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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_StandaloneAddTest
31 */
32 class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 function testStandaloneGrantAdd() {
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 $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload');
53
54 // create new contact using dialog
55 $contact = $this->createDialogContact();
56
57 // select grant Status
58 $this->select("status_id", "value=1");
59
60 // select grant type
61 $this->select("grant_type_id", "value=1");
62
63 // total amount
64 $this->type("amount_total", "100");
65
66 // amount requested
67 $this->type("amount_requested", "100");
68
69 // amount granted
70 $this->type("amount_granted", "90");
71
72 // fill in application received Date
73 $this->webtestFillDate('application_received_date');
74
75 // fill in decision Date
76 $this->webtestFillDate('decision_date');
77
78 // fill in money transfered date
79 $this->webtestFillDate('money_transfer_date');
80
81 // fill in grant due Date
82 $this->webtestFillDate('grant_due_date');
83
84 // check grant report recieved.
85 $this->check("grant_report_received");
86
87 // grant note
88 $this->type("note", "Grant Note");
89
90 // Clicking save.
91 $this->clickLink("_qf_Grant_upload", "xpath=//div[@class='view-content']//table//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
92
93 //click through to the Grant view screen
94 $this->click("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
95
96 $this->waitForElementPresent("_qf_GrantView_cancel-bottom");
97
98 $expected = array(
99 'Grant Status' => 'Submitted',
100 'Grant Type' => 'Emergency',
101 'Amount Requested' => '$ 100.00',
102 'Amount Granted' => '$ 90.00',
103 'Notes' => 'Grant Note',
104 );
105
106 $this->webtestVerifyTabularData($expected);
107 }
108 }
109