Import from SVN (r45945, r596)
[civicrm-core.git] / tests / phpunit / WebTest / Generic / CheckActivityTest.php
CommitLineData
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. |
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Generic_CheckActivityTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testCheckDashboardElements() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
38 // class attributes.
39 $this->open($this->sboxPath);
40
41 // Log in using webtestLogin() method
42 $this->webtestLogin();
43
44 // Adding contact with randomized first name
45 // We're using Quick Add block on the main page for this.
46 $contactFirstName1 = substr(sha1(rand()), 0, 7);
47 $this->webtestAddContact($contactFirstName1, "Devis", TRUE);
48
49 // Adding another contact with randomized first name
50 // We're using Quick Add block on the main page for this.
51 $contactFirstName2 = substr(sha1(rand()), 0, 7);
52 $this->webtestAddContact($contactFirstName2, "Anderson", TRUE);
53 $this->open($this->sboxPath . "civicrm/activity?reset=1&action=add&context=standalone");
54
55 // make sure the form loaded, check the end element
56 $this->waitForElementPresent("_qf_Activity_upload");
57 $this->select("activity_type_id", "label=Meeting");
58
59 $this->click("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1");
60 $this->type("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$contactFirstName1");
61 $this->typeKeys("css=tr.crm-activity-form-block-target_contact_id input#token-input-contact_1", "$contactFirstName1");
62
63 // ...waiting for drop down with results to show up...
64 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
65 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
66
67 // ...need to use mouseDownAt on first result (which is a li element), click does not work
68 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
69
70 // ...again, waiting for the box with contact name to show up (span with delete token class indicates that it's present)...
71 $this->waitForElementPresent("css=tr.crm-activity-form-block-target_contact_id td ul li span.token-input-delete-token-facebook");
72
73 // Now we're doing the same for "Assigned To" field.
74 // Typing contact's name into the field (using typeKeys(), not type()!)...
75 $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id");
76 $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$contactFirstName2");
77 $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$contactFirstName2");
78
79 // ...waiting for drop down with results to show up...
80 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
81 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
82
83 //..need to use mouseDownAt on first result (which is a li element), click does not work
84 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
85
86 // ...again, waiting for the box with contact name to show up...
87 $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook");
88 }
89}
90
91