| 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_Case_CaseDashboardTest |
| 31 | */ |
| 32 | class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { |
| 33 | |
| 34 | protected function setUp() { |
| 35 | parent::setUp(); |
| 36 | } |
| 37 | |
| 38 | public function testAllOrMyCases() { |
| 39 | // Log in as admin first to verify permissions for CiviCase |
| 40 | $this->webtestLogin('admin'); |
| 41 | |
| 42 | // Enable CiviCase module if necessary |
| 43 | $this->enableComponents("CiviCase"); |
| 44 | |
| 45 | // let's give full CiviCase permissions to demo user (registered user). |
| 46 | $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); |
| 47 | $this->changePermissions($permission); |
| 48 | |
| 49 | // Log in as normal user |
| 50 | $this->webtestLogin(); |
| 51 | |
| 52 | $this->openCiviPage('case', 'reset=1'); |
| 53 | |
| 54 | // Should default to My Cases |
| 55 | $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.'); |
| 56 | // The header text of the table changes too |
| 57 | $this->assertElementContainsText('crm-container', "Summary of Involvement"); |
| 58 | |
| 59 | $this->clickLink("name=allupcoming value=1", "css=a.button"); |
| 60 | |
| 61 | $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.'); |
| 62 | $this->assertElementContainsText('crm-container', "Summary of All Cases"); |
| 63 | |
| 64 | // Go back to dashboard |
| 65 | $this->openCiviPage('case', 'reset=1', 'css=a.button'); |
| 66 | |
| 67 | // Click on find my cases and check if right radio is checked |
| 68 | $this->clickLink("name=find_my_cases", "css=input.crm-form-submit"); |
| 69 | $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.'); |
| 70 | |
| 71 | //Add case to get drilldown cell on Case dashboard |
| 72 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); |
| 73 | |
| 74 | // We're using pop-up New Contact dialog |
| 75 | $this->createDialogContact('client_id'); |
| 76 | |
| 77 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. |
| 78 | $caseTypeLabel = "Adult Day Care Referral"; |
| 79 | // activity types we expect for this case type |
| 80 | $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation"); |
| 81 | $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client"); |
| 82 | $caseStatusLabel = "Ongoing"; |
| 83 | $subject = "Safe daytime setting - senior female"; |
| 84 | $this->select("medium_id", "value=1"); |
| 85 | $location = "Main offices"; |
| 86 | $this->type("activity_location", $location); |
| 87 | $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; |
| 88 | $this->fireEvent('activity_details', 'focus'); |
| 89 | $this->fillRichTextField("activity_details", $details, 'CKEditor'); |
| 90 | $this->type("activity_subject", $subject); |
| 91 | |
| 92 | $this->select("case_type_id", "label={$caseTypeLabel}"); |
| 93 | $this->select("status_id", "label={$caseStatusLabel}"); |
| 94 | |
| 95 | // Choose Case Start Date. |
| 96 | // Using helper webtestFillDate function. |
| 97 | $this->webtestFillDate('start_date', 'now'); |
| 98 | $today = date('F jS, Y', strtotime('now')); |
| 99 | |
| 100 | $this->type("duration", "20"); |
| 101 | $this->clickLink("_qf_Case_upload-bottom", "_qf_CaseView_cancel-bottom"); |
| 102 | |
| 103 | // Is status message correct? |
| 104 | $this->waitForText('crm-notification-container', "Case opened successfully."); |
| 105 | |
| 106 | // Go back to dashboard |
| 107 | $this->openCiviPage('case', 'reset=1'); |
| 108 | |
| 109 | // Click on a drilldown cell and check if right radio is checked |
| 110 | $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit"); |
| 111 | $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.'); |
| 112 | |
| 113 | // Go back to dashboard and reset to my cases |
| 114 | $this->openCiviPage('case', 'reset=1', 'css=a.button'); |
| 115 | $this->clickLink("name=allupcoming value=0", "css=a.button"); |
| 116 | |
| 117 | // Click on a drilldown cell and check if right radio is checked |
| 118 | $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.crm-form-submit"); |
| 119 | $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.'); |
| 120 | } |
| 121 | } |