Merge pull request #10379 from seanmadsen/CRM-20301
[civicrm-core.git] / tests / phpunit / WebTest / Contact / PrevNextTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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_Contact_PrevNextTest
31 */
32 class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testPrevNext() {
39 $this->webtestLogin();
40
41 /* add new group */
42
43 $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload');
44
45 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
46 $this->type("title", $groupName);
47
48 // fill description
49 $this->type("description", "Adding new group.");
50
51 // check Access Control
52 $this->click("group_type[1]");
53
54 // Clicking save.
55 $this->click("_qf_Edit_upload");
56 $this->waitForPageToLoad($this->getTimeoutMsec());
57
58 /* add contacts */
59
60 // Individual 1
61 $contact1 = substr(sha1(rand()), 0, 7);
62 $this->webtestAddContact($contact1, "AAA", "{$contact1}@example.com");
63
64 // Add Individual 1 to group
65 $this->click('css=li#tab_group a');
66 $this->waitForElementPresent('_qf_GroupContact_next');
67 $this->select('group_id', "label={$groupName}");
68 $this->click('_qf_GroupContact_next');
69 $this->waitForText('crm-notification-container', "Added to Group");
70
71 // Individual 2
72 $contact2 = substr(sha1(rand()), 0, 7);
73 $this->webtestAddContact($contact2, "BBB", "{$contact2}@example.com");
74
75 // Add Individual 2 to group
76 $this->click('css=li#tab_group a');
77 $this->waitForElementPresent('_qf_GroupContact_next');
78 $this->select('group_id', "label={$groupName}");
79 $this->click('_qf_GroupContact_next');
80 $this->waitForText('crm-notification-container', "Added to Group");
81
82 // Individual 3
83 $contact3 = substr(sha1(rand()), 0, 7);
84 $this->webtestAddContact($contact3, "CCC", "{$contact3}@example.com");
85
86 // Add Individual 3 to group
87 $this->click('css=li#tab_group a');
88 $this->waitForElementPresent('_qf_GroupContact_next');
89 $this->select('group_id', "label={$groupName}");
90 $this->click('_qf_GroupContact_next');
91 $this->waitForText('crm-notification-container', "Added to Group");
92
93 // Search contacts
94 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
95
96 $this->select('group', "label={$groupName}");
97 $this->click("_qf_Basic_refresh");
98 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
99 $this->assertElementContainsText('search-status', "3 Contacts");
100
101 $this->click("xpath=//div[@class='crm-search-results']//table/tbody/tr[1]/td[3]/a");
102 $this->waitForPageToLoad($this->getTimeoutMsec());
103
104 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
105 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
106
107 $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
108 $this->waitForPageToLoad($this->getTimeoutMsec());
109 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact2} BBB");
110 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
111 $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
112
113 $this->click("xpath=//ul[@id='actions']/li[@class='crm-next-action']/a");
114 $this->waitForPageToLoad($this->getTimeoutMsec());
115 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact3} CCC");
116 $this->assertElementContainsText('css=li.crm-previous-action a span', "Previous");
117
118 $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
123
124 $this->click("xpath=//ul[@id='actions']/li[@class='crm-previous-action']/a");
125 $this->waitForPageToLoad($this->getTimeoutMsec());
126 $this->assertElementContainsText('css=div.crm-summary-display_name', "{$contact1} AAA");
127 $this->assertElementContainsText('css=li.crm-next-action a span', "Next");
128 }
129
130 }