whitespace cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Admin / RelationshipTypeAddTest.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
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class 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.
8f737a72 63 $this->assertElementContainsText('crm-notification-container', 'The Relationship Type has been saved.',
6a488035
TO
64 "Status message didn't show up after saving!"
65 );
66
67 //validate data.
68 $data = array(
69 'Relationship A to B' => $labelAB,
70 'Relationship B to A' => $labelBA,
71 'Contact Type A' => 'Individual',
72 'Contact Type B' => 'Individual',
73 );
74 foreach ($data as $param => $val) {
8f737a72 75 $this->assertElementContainsText('option11', $val, "Could not able to save $param");
6a488035
TO
76 }
77 }
78
79 function testRelationshipTypeAddValidateFormRules() {
80
6a488035
TO
81 $this->webtestLogin();
82 $this->waitForPageToLoad($this->getTimeoutMsec());
83
84 $this->click('link=CiviCRM');
85 $this->waitForPageToLoad($this->getTimeoutMsec());
86
87 //jump directly to relationship type selector.
8f737a72 88 $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
6a488035
TO
89
90 //validate form rules.
91 $this->click('link=Add Relationship Type');
92 $this->waitForPageToLoad($this->getTimeoutMsec());
93
94 $this->select('contact_types_a', 'value=Individual');
95 $this->select('contact_types_b', 'value=Individual');
96 $description = 'Test Relationship Type Description';
97 $this->type('description', $description);
98
99 $this->click('_qf_RelationshipType_next-bottom');
100 $this->waitForPageToLoad($this->getTimeoutMsec());
8f737a72 101 $this->assertElementContainsText('crm-notification-container', 'Relationship Label-A to B is a required field.',
6a488035
TO
102 'Required form rule for Label A - B seems to be broken.'
103 );
104
105 //enter the relationship type values.
106 $labelAB = 'Test Relationship Type A - B - DUPLICATE TO BE' . rand();
107 $labelBA = 'Test Relationship Type B - A - DUPLICATE TO BE' . rand();
108 $this->type('label_a_b', $labelAB);
109 $this->type('label_b_a', $labelBA);
110 $this->select('contact_types_a', "value=Individual");
111 $this->select('contact_types_b', "value=Individual");
112 $this->type('description', 'Test Relationship Type Description');
113 $this->click('_qf_RelationshipType_next-bottom');
114 $this->waitForPageToLoad($this->getTimeoutMsec());
115
8f737a72 116 $this->openCiviPage('admin/reltype', 'reset=1&action=browse');
6a488035
TO
117 $this->click('link=Add Relationship Type');
118 $this->waitForPageToLoad($this->getTimeoutMsec());
119
120 $this->type('label_a_b', $labelAB);
121 $this->type('label_b_a', $labelBA);
122 $this->click('_qf_RelationshipType_next-bottom');
8f737a72 123
6a488035 124 $this->waitForPageToLoad($this->getTimeoutMsec());
8f737a72 125 $this->assertElementContainsText('crm-notification-container', 'Label already exists in Database.',
6a488035
TO
126 'Unique relationship type label form rule seems to be broken.'
127 );
128 }
129}
130