Commit | Line | Data |
---|---|---|
6a488035 TO |
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() { | |
6a488035 TO |
40 | // Log in as admin first to verify permissions for CiviGrant |
41 | $this->webtestLogin(TRUE); | |
42 | ||
43 | // Enable CiviGrant module if necessary | |
b9715b8a | 44 | $this->enableComponents("CiviGrant"); |
6a488035 TO |
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->open($this->sboxPath . "civicrm/grant/add?reset=1&context=standalone"); | |
52 | ||
53 | // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit | |
54 | // button at the end of this page to show up, to make sure it's fully loaded. | |
55 | $this->waitForElementPresent("_qf_Grant_upload"); | |
56 | ||
57 | // Let's start filling the form with values. | |
58 | ||
59 | // create new contact using dialog | |
60 | $firstName = substr(sha1(rand()), 0, 7); | |
61 | $this->webtestNewDialogContact($firstName, "Grantor", $firstName . "@example.com"); | |
62 | ||
63 | // select grant Status | |
64 | $this->select("status_id", "value=1"); | |
65 | ||
66 | // select grant type | |
67 | $this->select("grant_type_id", "value=1"); | |
68 | ||
69 | // total amount | |
70 | $this->type("amount_total", "100"); | |
71 | ||
72 | // amount requested | |
73 | $this->type("amount_requested", "100"); | |
74 | ||
75 | // amount granted | |
76 | $this->type("amount_granted", "90"); | |
77 | ||
78 | // fill in application received Date | |
79 | $this->webtestFillDate('application_received_date'); | |
80 | ||
81 | // fill in decision Date | |
82 | $this->webtestFillDate('decision_date'); | |
83 | ||
84 | // fill in money transfered date | |
85 | $this->webtestFillDate('money_transfer_date'); | |
86 | ||
87 | // fill in grant due Date | |
88 | $this->webtestFillDate('grant_due_date'); | |
89 | ||
90 | // check grant report recieved. | |
91 | $this->check("grant_report_received"); | |
92 | ||
93 | // grant note | |
94 | $this->type("note", "Grant Note"); | |
95 | ||
96 | // Clicking save. | |
97 | $this->click("_qf_Grant_upload"); | |
98 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
99 | ||
100 | // verify if Grant is created | |
101 | $this->waitForElementPresent("xpath=//div[@id='Grants']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); | |
102 | ||
103 | //click through to the Grant view screen | |
104 | $this->click("xpath=//div[@id='Grants']//table/tbody/tr[1]/td[8]/span/a[text()='View']"); | |
105 | ||
106 | $this->waitForElementPresent("_qf_GrantView_cancel-bottom"); | |
107 | ||
108 | $expected = array( | |
109 | 2 => 'Submitted', | |
110 | 3 => 'Emergency', | |
111 | 8 => '$ 100.00', | |
112 | 10 => '$ 90.00', | |
113 | 13 => 'Grant Note', | |
114 | ); | |
115 | ||
116 | foreach ($expected as $label => $value) { | |
117 | $this->verifyText("xpath=id('GrantView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value)); | |
118 | } | |
119 | } | |
120 | } | |
121 |