3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Admin_RelationshipTypeAddTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testRelationshipTypeAdd() {
37 $this->webtestLogin();
38 $this->waitForPageToLoad($this->getTimeoutMsec());
40 $this->click('link=CiviCRM');
41 $this->waitForPageToLoad($this->getTimeoutMsec());
43 //jump directly to relationship type selector.
44 $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
46 //load the form to add new relationship type.
47 $this->click('link=Add Relationship Type');
48 $this->waitForPageToLoad($this->getTimeoutMsec());
50 //enter the relationship type values.
51 $labelAB = 'Test Relationship Type A - B -' . rand();
52 $labelBA = 'Test Relationship Type B - A -' . rand();
53 $this->type('label_a_b', $labelAB);
54 $this->type('label_b_a', $labelBA);
55 $this->select('contact_types_a', "value=Individual");
56 $this->select('contact_types_b', "value=Individual");
57 $this->type('description', 'Test Relationship Type Description');
60 $this->click('_qf_RelationshipType_next-bottom');
61 $this->waitForPageToLoad($this->getTimeoutMsec());
64 $this->assertElementContainsText('crm-notification-container', 'The Relationship Type has been saved.',
65 "Status message didn't show up after saving!"
70 'Relationship A to B' => $labelAB,
71 'Relationship B to A' => $labelBA,
72 'Contact Type A' => 'Individual',
73 'Contact Type B' => 'Individual',
75 foreach ($data as $param => $val) {
76 $this->assertElementContainsText('option11', $val, "Could not able to save $param");
80 function testRelationshipTypeAddValidateFormRules() {
82 $this->webtestLogin();
83 $this->waitForPageToLoad($this->getTimeoutMsec());
85 $this->click('link=CiviCRM');
86 $this->waitForPageToLoad($this->getTimeoutMsec());
88 //jump directly to relationship type selector.
89 $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
91 //validate form rules.
92 $this->click('link=Add Relationship Type');
93 $this->waitForPageToLoad($this->getTimeoutMsec());
95 $this->select('contact_types_a', 'value=Individual');
96 $this->select('contact_types_b', 'value=Individual');
97 $description = 'Test Relationship Type Description';
98 $this->type('description', $description);
100 $this->click('_qf_RelationshipType_next-bottom');
101 $this->waitForPageToLoad($this->getTimeoutMsec());
102 $this->assertElementContainsText('crm-notification-container', 'Relationship Label-A to B is a required field.',
103 'Required form rule for Label A - B seems to be broken.'
106 //enter the relationship type values.
107 $labelAB = 'Test Relationship Type A - B - DUPLICATE TO BE' . rand();
108 $labelBA = 'Test Relationship Type B - A - DUPLICATE TO BE' . rand();
109 $this->type('label_a_b', $labelAB);
110 $this->type('label_b_a', $labelBA);
111 $this->select('contact_types_a', "value=Individual");
112 $this->select('contact_types_b', "value=Individual");
113 $this->type('description', 'Test Relationship Type Description');
114 $this->click('_qf_RelationshipType_next-bottom');
115 $this->waitForPageToLoad($this->getTimeoutMsec());
117 $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
118 $this->click('link=Add Relationship Type');
119 $this->waitForPageToLoad($this->getTimeoutMsec());
121 $this->type('label_a_b', $labelAB);
122 $this->type('label_b_a', $labelBA);
123 $this->click('_qf_RelationshipType_next-bottom');
125 $this->waitForPageToLoad($this->getTimeoutMsec());
126 $this->assertElementContainsText('crm-notification-container', 'Label already exists in Database.',
127 'Unique relationship type label form rule seems to be broken.'