whitespace cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Activity / ContactContextAddTest.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 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
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testContactContextActivityAdd() {
6a488035
TO
35 $this->webtestLogin();
36
37 // Adding Adding contact with randomized first name for test testContactContextActivityAdd
38 // We're using Quick Add block on the main page for this.
39 $firstName1 = substr(sha1(rand()), 0, 7);
40 $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name");
41 $firstName2 = substr(sha1(rand()), 0, 7);
42 $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name");
43
6a488035
TO
44 $this->click("css=li#tab_activity a");
45
46 // waiting for the activity dropdown to show up
47 $this->waitForElementPresent("other_activity");
48
49 // Select the activity type from the activity dropdown
50 $this->select("other_activity", "label=Meeting");
42daf119 51 $this->waitForPageToLoad($this->getTimeoutMsec());
6a488035
TO
52
53 // 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_Activity_upload");
56
6a488035 57 // ...and verifying if the page contains properly formatted display name for chosen contact.
bb21371e 58 $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook', 'Anderson, ' . $firstName2, 'Contact not found in line ' . __LINE__);
6a488035
TO
59
60 // Now we're filling the "Assigned To" field.
61 // Typing contact's name into the field (using typeKeys(), not type()!)...
62 $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id");
63 $this->type("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1);
64 $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", $firstName1);
65
66 // ...waiting for drop down with results to show up...
67 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
68 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
69
70 // ...need to use mouseDownAt on first result (which is a li element), click does not work
71 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
72
73 // ...again, waiting for the box with contact name to show up...
74 $this->waitForElementPresent("css=tr.crm-activity-form-block-assignee_contact_id td ul li span.token-input-delete-token-facebook");
75
76 // ...and verifying if the page contains properly formatted display name for chosen contact.
bb21371e 77 $this->assertElementContainsText('css=tr.crm-activity-form-block-assignee_contact_id td ul li.token-input-token-facebook', 'Summerson, ' . $firstName1, 'Contact not found in line ' . __LINE__);
6a488035
TO
78
79 // Since we're here, let's check if screen help is being displayed properly
6a488035 80
bb21371e 81 $this->assertElementContainsText('css=tr.crm-activity-form-block-assignee_contact_id td span.description', 'You can optionally assign this activity to someone', 'Help text is missing.');
6a488035
TO
82 // Putting the contents into subject field - assigning the text to variable, it'll come in handy later
83 $subject = "This is subject of test activity being added through activity tab of contact summary screen.";
84 // For simple input fields we can use field id as selector
85 $this->type("subject", $subject);
86 $this->type("location", "Some location needs to be put in this field.");
87
88 // Choosing the Date.
89 // Please note that we don't want to put in fixed date, since
90 // we want this test to work in the future and not fail because
91 // of date being set in the past. Therefore, using helper webtestFillDateTime function.
92 $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM');
93
94 // Setting duration.
95 $this->type("duration", "30");
96
97 // Putting in details.
98 $this->type("details", "Really brief details information.");
99
100 // Making sure that status is set to Scheduled (using value, not label).
101 $this->select("status_id", "value=1");
102
103 // Setting priority.
104 $this->select("priority_id", "value=1");
105
106 // Adding attachment
107 // TODO TBD
108
109 // Scheduling follow-up.
110 $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header");
111 $this->select("followup_activity_type_id", "value=1");
112 $this->webtestFillDateTime('followup_date', '+2 months 10:00AM');
113 $this->type("followup_activity_subject", "This is subject of schedule follow-up activity");
114
115 // Clicking save.
116 $this->click("_qf_Activity_upload");
117 $this->waitForPageToLoad($this->getTimeoutMsec());
118
119 // Is status message correct?
bb21371e 120 $this->assertElementContainsText('crm-notification-container', "Activity '$subject' has been saved.", "Status message didn't show up after saving.");
6a488035
TO
121
122 $this->waitForElementPresent("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[9]/span/a[text()='View']");
123
124 // click through to the Activity view screen
125 $this->click("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[9]/span/a[text()='View']");
126 $this->waitForElementPresent('_qf_Activity_cancel-bottom');
127
128 // verify Activity created
129 $this->webtestVerifyTabularData(
130 array(
131 'Subject' => $subject,
132 'Location' => 'Some location needs to be put in this field.',
133 'Status' => 'Scheduled',
134 'Duration' => '30',
135 // Tough luck filling in WYSIWYG editor, so skipping verification for now.
136 //'Details' => 'Really brief details information.',
137 'Priority' => 'Urgent',
138 ),
139 "/label"
140 );
141
142 $this->webtestVerifyTabularData(
143 array(
144 'With Contact' => "Anderson, {$firstName2}",
145 'Assigned To' => "Summerson, {$firstName1}",
146 )
147 );
148 }
149}
150