Merge pull request #86 from dlobo/CRM-12051
[civicrm-core.git] / tests / phpunit / WebTest / Grant / StandaloneAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase {
30
31 protected $captureScreenshotOnFailure = TRUE;
32 protected $screenshotPath = '/tmp/';
33 protected $screenshotUrl = 'http://api.dev.civicrm.org/sc/';
34
35 protected function setUp() {
36 parent::setUp();
37 }
38
39 function testStandaloneGrantAdd() {
40 // Log in as admin first to verify permissions for CiviGrant
41 $this->webtestLogin(TRUE);
42
43 // Enable CiviGrant module if necessary
44 $this->enableComponents("CiviGrant");
45
46 // let's give full CiviGrant permissions to demo user (registered user).
47 $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant');
48 $this->changePermissions($permission);
49
50 // Go directly to the URL of the screen that you will be testing (New Contribution-standalone).
51 $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload');
52
53 // Let's start filling the form with values.
54
55 // create new contact using dialog
56 $firstName = substr(sha1(rand()), 0, 7);
57 $this->webtestNewDialogContact($firstName, "Grantor", $firstName . "@example.com");
58
59 // select grant Status
60 $this->select("status_id", "value=1");
61
62 // select grant type
63 $this->select("grant_type_id", "value=1");
64
65 // total amount
66 $this->type("amount_total", "100");
67
68 // amount requested
69 $this->type("amount_requested", "100");
70
71 // amount granted
72 $this->type("amount_granted", "90");
73
74 // fill in application received Date
75 $this->webtestFillDate('application_received_date');
76
77 // fill in decision Date
78 $this->webtestFillDate('decision_date');
79
80 // fill in money transfered date
81 $this->webtestFillDate('money_transfer_date');
82
83 // fill in grant due Date
84 $this->webtestFillDate('grant_due_date');
85
86 // check grant report recieved.
87 $this->check("grant_report_received");
88
89 // grant note
90 $this->type("note", "Grant Note");
91
92 // Clicking save.
93 $this->click("_qf_Grant_upload");
94 $this->waitForPageToLoad($this->getTimeoutMsec());
95
96 // verify if Grant is created
97 $this->waitForElementPresent("xpath=//div[@id='Grants']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
98
99 //click through to the Grant view screen
100 $this->click("xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
101
102 $this->waitForElementPresent("_qf_GrantView_cancel-bottom");
103
104 $expected = array(
105 'Grant Status' => 'Submitted',
106 'Grant Type' => 'Emergency',
107 'Amount Requested' => '$ 100.00',
108 'Amount Granted' => '$ 90.00',
109 'Notes' => 'Grant Note',
110 );
111
112 $this->webtestVerifyTabularData($expected);
113 }
114 }
115