Merge pull request #159 from lcdservices/master
[civicrm-core.git] / tests / phpunit / WebTest / Contact / PrevNextTest.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
27
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testPrevNext() {
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 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
47
48
49 /* add new group */
50
d8bd5fb9 51 $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload');
6a488035
TO
52
53 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
54 $this->type("title", $groupName);
55
56 // fill description
57 $this->type("description", "Adding new group.");
58
59 // check Access Control
60 $this->click("group_type[1]");
61
62 // Clicking save.
63 $this->click("_qf_Edit_upload");
64 $this->waitForPageToLoad($this->getTimeoutMsec());
65
66 /* add contacts */
67
68 // Individual 1
69 $contact1 = substr(sha1(rand()), 0, 7);
70 $this->webtestAddContact($contact1, "AAA", "{$contact1}@example.com");
71
72 // Add Individual 1 to group
73 $this->click('css=li#tab_group a');
74 $this->waitForElementPresent('_qf_GroupContact_next');
75 $this->select('group_id', "label={$groupName}");
76 $this->click('_qf_GroupContact_next');
77 $this->waitForPageToLoad($this->getTimeoutMsec());
78 $this->assertElementContainsText('crm-notification-container', "Added to Group");
79
80 // Individual 2
81 $contact2 = substr(sha1(rand()), 0, 7);
82 $this->webtestAddContact($contact2, "BBB", "{$contact2}@example.com");
83
84 // Add Individual 2 to group
85 $this->click('css=li#tab_group a');
86 $this->waitForElementPresent('_qf_GroupContact_next');
87 $this->select('group_id', "label={$groupName}");
88 $this->click('_qf_GroupContact_next');
89 $this->waitForPageToLoad($this->getTimeoutMsec());
90 $this->assertElementContainsText('crm-notification-container', "Added to Group");
91
92 // Individual 3
93 $contact3 = substr(sha1(rand()), 0, 7);
94 $this->webtestAddContact($contact3, "CCC", "{$contact3}@example.com");
95
96 // Add Individual 3 to group
97 $this->click('css=li#tab_group a');
98 $this->waitForElementPresent('_qf_GroupContact_next');
99 $this->select('group_id', "label={$groupName}");
100 $this->click('_qf_GroupContact_next');
101 $this->waitForPageToLoad($this->getTimeoutMsec());
102 $this->assertElementContainsText('crm-notification-container', "Added to Group");
103
104 // Search contacts
d8bd5fb9 105 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
6a488035
TO
106
107 $this->select('group', "label={$groupName}");
108 $this->click("_qf_Basic_refresh");
109 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
d8bd5fb9 110 $this->assertElementContainsText('search-status', "3 Contacts");
6a488035
TO
111
112 $this->click("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[3]/a");
113 $this->waitForPageToLoad($this->getTimeoutMsec());
114
d8bd5fb9
RN
115 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
116 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
6a488035
TO
117
118 $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
d8bd5fb9
RN
120 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact2} BBB");
121 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
122 $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
6a488035
TO
123
124 $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
125 $this->waitForPageToLoad($this->getTimeoutMsec());
d8bd5fb9
RN
126 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact3} CCC");
127 $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
6a488035
TO
128
129 $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
130 $this->waitForPageToLoad($this->getTimeoutMsec());
d8bd5fb9
RN
131 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact2} BBB");
132 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
133 $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
6a488035
TO
134
135 $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
136 $this->waitForPageToLoad($this->getTimeoutMsec());
d8bd5fb9
RN
137 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
138 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
6a488035
TO
139 }
140}
141