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