Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Admin_RelationshipTypeAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testRelationshipTypeAdd() { |
6a488035 | 39 | |
6a488035 TO |
40 | $this->webtestLogin(); |
41 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
42 | ||
43 | $this->click('link=CiviCRM'); | |
44 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
45 | ||
46 | //jump directly to relationship type selector. | |
8f737a72 | 47 | $this->openCiviPage('admin/reltype', 'reset=1&action=browse'); |
6a488035 TO |
48 | |
49 | //load the form to add new relationship type. | |
50 | $this->click('link=Add Relationship Type'); | |
44c45561 | 51 | $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); |
6a488035 TO |
52 | |
53 | //enter the relationship type values. | |
54 | $labelAB = 'Test Relationship Type A - B -' . rand(); | |
55 | $labelBA = 'Test Relationship Type B - A -' . rand(); | |
56 | $this->type('label_a_b', $labelAB); | |
57 | $this->type('label_b_a', $labelBA); | |
58 | $this->select('contact_types_a', "value=Individual"); | |
59 | $this->select('contact_types_b', "value=Individual"); | |
60 | $this->type('description', 'Test Relationship Type Description'); | |
61 | ||
62 | //save the data. | |
63 | $this->click('_qf_RelationshipType_next-bottom'); | |
6a488035 TO |
64 | |
65 | //does data saved. | |
6c5f7368 | 66 | $this->waitForText('crm-notification-container', 'The Relationship Type has been saved.'); |
6a488035 | 67 | |
44c45561 | 68 | $this->waitForElementPresent('link=Add Relationship Type'); |
6a488035 TO |
69 | //validate data. |
70 | $data = array( | |
71 | 'Relationship A to B' => $labelAB, | |
72 | 'Relationship B to A' => $labelBA, | |
73 | 'Contact Type A' => 'Individual', | |
74 | 'Contact Type B' => 'Individual', | |
75 | ); | |
76 | foreach ($data as $param => $val) { | |
60ad1b50 | 77 | $this->assertElementContainsText("xpath=//table[@class='display dataTable no-footer']", $val, "Could not able to save $param"); |
6a488035 TO |
78 | } |
79 | } | |
80 | ||
00be9182 | 81 | public function testRelationshipTypeAddValidateFormRules() { |
6a488035 | 82 | |
6a488035 TO |
83 | $this->webtestLogin(); |
84 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
85 | ||
86 | $this->click('link=CiviCRM'); | |
87 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
88 | ||
89 | //jump directly to relationship type selector. | |
8f737a72 | 90 | $this->openCiviPage('admin/reltype', 'reset=1&action=browse'); |
6a488035 TO |
91 | |
92 | //validate form rules. | |
93 | $this->click('link=Add Relationship Type'); | |
44c45561 | 94 | $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); |
6a488035 TO |
95 | |
96 | $this->select('contact_types_a', 'value=Individual'); | |
97 | $this->select('contact_types_b', 'value=Individual'); | |
98 | $description = 'Test Relationship Type Description'; | |
99 | $this->type('description', $description); | |
100 | ||
101 | $this->click('_qf_RelationshipType_next-bottom'); | |
c51f8adb | 102 | $this->waitForText("xpath=//*[@id='RelationshipType']/div[2]/table/tbody/tr[1]/td[2]/label[@class='crm-inline-error']", 'This field is required.'); |
6a488035 TO |
103 | |
104 | //enter the relationship type values. | |
105 | $labelAB = 'Test Relationship Type A - B - DUPLICATE TO BE' . rand(); | |
106 | $labelBA = 'Test Relationship Type B - A - DUPLICATE TO BE' . rand(); | |
107 | $this->type('label_a_b', $labelAB); | |
108 | $this->type('label_b_a', $labelBA); | |
109 | $this->select('contact_types_a', "value=Individual"); | |
110 | $this->select('contact_types_b', "value=Individual"); | |
111 | $this->type('description', 'Test Relationship Type Description'); | |
112 | $this->click('_qf_RelationshipType_next-bottom'); | |
44c45561 | 113 | $this->waitForElementPresent('link=Add Relationship Type'); |
6a488035 | 114 | |
8f737a72 | 115 | $this->openCiviPage('admin/reltype', 'reset=1&action=browse'); |
6a488035 | 116 | $this->click('link=Add Relationship Type'); |
44c45561 | 117 | $this->waitForElementPresent('_qf_RelationshipType_next-bottom'); |
6a488035 TO |
118 | |
119 | $this->type('label_a_b', $labelAB); | |
120 | $this->type('label_b_a', $labelBA); | |
121 | $this->click('_qf_RelationshipType_next-bottom'); | |
8f737a72 | 122 | |
6c5f7368 | 123 | $this->waitForText('crm-notification-container', 'Label already exists in Database.'); |
6a488035 | 124 | } |
96025800 | 125 | |
6a488035 | 126 | } |