| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.6 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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("//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 |
| 72 | $this->waitForText('css=span.ui-dialog-title', "New Grant"); |
| 73 | $this->waitForElementPresent('status_id'); |
| 74 | |
| 75 | // check contact name on Grant form |
| 76 | |
| 77 | // select grant Status |
| 78 | $this->select('status_id', 'value=1'); |
| 79 | |
| 80 | // select grant type |
| 81 | $this->select('grant_type_id', 'value=1'); |
| 82 | |
| 83 | // total amount |
| 84 | $this->type('amount_total', '200'); |
| 85 | |
| 86 | // amount requested |
| 87 | $this->type('amount_requested', '200'); |
| 88 | |
| 89 | // amount granted |
| 90 | $this->type('amount_granted', '190'); |
| 91 | |
| 92 | // fill in application received Date |
| 93 | $this->webtestFillDate('application_received_date', 'now'); |
| 94 | |
| 95 | // fill in decision Date |
| 96 | $this->webtestFillDate('decision_date', 'now'); |
| 97 | |
| 98 | // fill in money transfered date |
| 99 | $this->webtestFillDate('money_transfer_date', 'now'); |
| 100 | |
| 101 | // fill in grant due Date |
| 102 | $this->webtestFillDate('grant_due_date', 'now'); |
| 103 | |
| 104 | // check grant report recieved. |
| 105 | $this->check('grant_report_received'); |
| 106 | |
| 107 | // grant rationale |
| 108 | $this->type('rationale', 'Grant Rationale for webtest'); |
| 109 | |
| 110 | // grant note |
| 111 | $this->type('note', "Grant Note for $firstName"); |
| 112 | |
| 113 | // Clicking save. |
| 114 | $this->clickLink('_qf_Grant_upload', "xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", FALSE); |
| 115 | |
| 116 | // click through to the Grant view screen |
| 117 | $this->clickLink("xpath=//div[@class='view-content']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_GrantView_cancel-bottom', FALSE); |
| 118 | |
| 119 | $gDate = date('F jS, Y', strtotime('now')); |
| 120 | |
| 121 | // verify tabular data for grant view |
| 122 | $this->webtestVerifyTabularData(array( |
| 123 | 'Name' => "$firstName $lastName", |
| 124 | 'Grant Status' => 'Submitted', |
| 125 | 'Grant Type' => 'Emergency', |
| 126 | 'Application Received' => $gDate, |
| 127 | 'Grant Decision' => $gDate, |
| 128 | 'Money Transferred' => $gDate, |
| 129 | 'Grant Report Due' => $gDate, |
| 130 | 'Amount Requested' => '$ 200.00', |
| 131 | 'Amount Granted' => '$ 190.00', |
| 132 | 'Grant Report Received?' => 'Yes', |
| 133 | 'Rationale' => 'Grant Rationale for webtest', |
| 134 | 'Notes' => "Grant Note for $firstName", |
| 135 | ) |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | } |