@@ -3,269 +3,269 @@ |
||
3 | 3 | class vCalTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testvCal() |
|
7 | - { |
|
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $vcal = new vCal(); |
|
6 | + public function testvCal() |
|
7 | + { |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $vcal = new vCal(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('vCal',$vcal); |
|
12 | - $this->assertInstanceOf('SugarBean',$vcal); |
|
11 | + $this->assertInstanceOf('vCal',$vcal); |
|
12 | + $this->assertInstanceOf('SugarBean',$vcal); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('vcals', 'table_name', $vcal); |
|
15 | - $this->assertAttributeEquals('vCals', 'module_dir', $vcal); |
|
16 | - $this->assertAttributeEquals('vCal', 'object_name', $vcal); |
|
14 | + $this->assertAttributeEquals('vcals', 'table_name', $vcal); |
|
15 | + $this->assertAttributeEquals('vCals', 'module_dir', $vcal); |
|
16 | + $this->assertAttributeEquals('vCal', 'object_name', $vcal); |
|
17 | 17 | |
18 | - $this->assertAttributeEquals(true, 'new_schema', $vcal); |
|
19 | - $this->assertAttributeEquals(false, 'tracker_visibility', $vcal); |
|
20 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $vcal); |
|
18 | + $this->assertAttributeEquals(true, 'new_schema', $vcal); |
|
19 | + $this->assertAttributeEquals(false, 'tracker_visibility', $vcal); |
|
20 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $vcal); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - public function testget_summary_text() |
|
25 | - { |
|
26 | - error_reporting(E_ERROR | E_PARSE); |
|
24 | + public function testget_summary_text() |
|
25 | + { |
|
26 | + error_reporting(E_ERROR | E_PARSE); |
|
27 | 27 | |
28 | - $vcal = new vCal(); |
|
28 | + $vcal = new vCal(); |
|
29 | 29 | |
30 | - //test without setting name |
|
31 | - $this->assertEquals(Null,$vcal->get_summary_text()); |
|
30 | + //test without setting name |
|
31 | + $this->assertEquals(Null,$vcal->get_summary_text()); |
|
32 | 32 | |
33 | - //test with name set |
|
34 | - $vcal->name = "test"; |
|
35 | - $this->assertEquals('',$vcal->get_summary_text()); |
|
33 | + //test with name set |
|
34 | + $vcal->name = "test"; |
|
35 | + $this->assertEquals('',$vcal->get_summary_text()); |
|
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - public function testfill_in_additional_list_fields() |
|
40 | - { |
|
39 | + public function testfill_in_additional_list_fields() |
|
40 | + { |
|
41 | 41 | |
42 | - $vcal = new vCal(); |
|
42 | + $vcal = new vCal(); |
|
43 | 43 | |
44 | - //execute the method and test if it works and does not throws an exception. |
|
45 | - try { |
|
46 | - $vcal->fill_in_additional_list_fields(); |
|
47 | - $this->assertTrue(true); |
|
48 | - } |
|
49 | - catch (Exception $e) { |
|
50 | - $this->fail(); |
|
51 | - } |
|
44 | + //execute the method and test if it works and does not throws an exception. |
|
45 | + try { |
|
46 | + $vcal->fill_in_additional_list_fields(); |
|
47 | + $this->assertTrue(true); |
|
48 | + } |
|
49 | + catch (Exception $e) { |
|
50 | + $this->fail(); |
|
51 | + } |
|
52 | 52 | |
53 | - $this->markTestIncomplete('method has no implementation'); |
|
54 | - } |
|
53 | + $this->markTestIncomplete('method has no implementation'); |
|
54 | + } |
|
55 | 55 | |
56 | - public function testfill_in_additional_detail_fields() |
|
57 | - { |
|
56 | + public function testfill_in_additional_detail_fields() |
|
57 | + { |
|
58 | 58 | |
59 | - $vcal = new vCal(); |
|
59 | + $vcal = new vCal(); |
|
60 | 60 | |
61 | - //execute the method and test if it works and does not throws an exception. |
|
62 | - try { |
|
63 | - $vcal->fill_in_additional_detail_fields(); |
|
64 | - $this->assertTrue(true); |
|
65 | - } |
|
66 | - catch (Exception $e) { |
|
67 | - $this->fail(); |
|
68 | - } |
|
61 | + //execute the method and test if it works and does not throws an exception. |
|
62 | + try { |
|
63 | + $vcal->fill_in_additional_detail_fields(); |
|
64 | + $this->assertTrue(true); |
|
65 | + } |
|
66 | + catch (Exception $e) { |
|
67 | + $this->fail(); |
|
68 | + } |
|
69 | 69 | |
70 | - $this->markTestIncomplete('method has no implementation'); |
|
71 | - } |
|
70 | + $this->markTestIncomplete('method has no implementation'); |
|
71 | + } |
|
72 | 72 | |
73 | - public function testget_list_view_data() |
|
74 | - { |
|
75 | - $vcal = new vCal(); |
|
73 | + public function testget_list_view_data() |
|
74 | + { |
|
75 | + $vcal = new vCal(); |
|
76 | 76 | |
77 | - //execute the method and test if it works and does not throws an exception. |
|
78 | - try { |
|
79 | - $vcal->get_list_view_data(); |
|
80 | - $this->assertTrue(true); |
|
81 | - } |
|
82 | - catch (Exception $e) { |
|
83 | - $this->fail(); |
|
84 | - } |
|
77 | + //execute the method and test if it works and does not throws an exception. |
|
78 | + try { |
|
79 | + $vcal->get_list_view_data(); |
|
80 | + $this->assertTrue(true); |
|
81 | + } |
|
82 | + catch (Exception $e) { |
|
83 | + $this->fail(); |
|
84 | + } |
|
85 | 85 | |
86 | - $this->markTestIncomplete('method has no implementation'); |
|
87 | - } |
|
86 | + $this->markTestIncomplete('method has no implementation'); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | - public function testget_freebusy_lines_cache() |
|
91 | - { |
|
90 | + public function testget_freebusy_lines_cache() |
|
91 | + { |
|
92 | 92 | |
93 | - $vcal = new vCal(); |
|
94 | - $user_bean = new User("1"); |
|
93 | + $vcal = new vCal(); |
|
94 | + $user_bean = new User("1"); |
|
95 | 95 | |
96 | - $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\n"; |
|
97 | - $expectedEnd ="END:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
96 | + $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\n"; |
|
97 | + $expectedEnd ="END:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
98 | 98 | |
99 | - $result = $vcal->get_freebusy_lines_cache($user_bean); |
|
99 | + $result = $vcal->get_freebusy_lines_cache($user_bean); |
|
100 | 100 | |
101 | - $this->assertStringStartsWith($expectedStart, $result); |
|
102 | - $this->assertStringEndsWith($expectedEnd, $result); |
|
101 | + $this->assertStringStartsWith($expectedStart, $result); |
|
102 | + $this->assertStringEndsWith($expectedEnd, $result); |
|
103 | 103 | |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - public function testcreate_sugar_freebusy() |
|
108 | - { |
|
109 | - global $locale, $timedate; |
|
107 | + public function testcreate_sugar_freebusy() |
|
108 | + { |
|
109 | + global $locale, $timedate; |
|
110 | 110 | |
111 | - $vcal = new vCal(); |
|
112 | - $user_bean = new User("1"); |
|
111 | + $vcal = new vCal(); |
|
112 | + $user_bean = new User("1"); |
|
113 | 113 | |
114 | - $now_date_time = $timedate->getNow(true); |
|
115 | - $start_date_time = $now_date_time->get("yesterday"); |
|
116 | - $end_date_time = $now_date_time->get("tomorrow"); |
|
114 | + $now_date_time = $timedate->getNow(true); |
|
115 | + $start_date_time = $now_date_time->get("yesterday"); |
|
116 | + $end_date_time = $now_date_time->get("tomorrow"); |
|
117 | 117 | |
118 | - $result = $vcal->create_sugar_freebusy($user_bean, $start_date_time, $end_date_time); |
|
119 | - $this->assertGreaterThanOrEqual(0,strlen($result)); |
|
118 | + $result = $vcal->create_sugar_freebusy($user_bean, $start_date_time, $end_date_time); |
|
119 | + $this->assertGreaterThanOrEqual(0,strlen($result)); |
|
120 | 120 | |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | - public function testget_vcal_freebusy() |
|
125 | - { |
|
126 | - $vcal = new vCal(); |
|
127 | - $user_focus = new User("1"); |
|
124 | + public function testget_vcal_freebusy() |
|
125 | + { |
|
126 | + $vcal = new vCal(); |
|
127 | + $user_focus = new User("1"); |
|
128 | 128 | |
129 | - $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\n"; |
|
130 | - $expectedEnd ="END:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
129 | + $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\n"; |
|
130 | + $expectedEnd ="END:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
131 | 131 | |
132 | - $result = $vcal->get_vcal_freebusy($user_focus); |
|
132 | + $result = $vcal->get_vcal_freebusy($user_focus); |
|
133 | 133 | |
134 | - $this->assertStringStartsWith($expectedStart, $result); |
|
135 | - $this->assertStringEndsWith($expectedEnd, $result); |
|
134 | + $this->assertStringStartsWith($expectedStart, $result); |
|
135 | + $this->assertStringEndsWith($expectedEnd, $result); |
|
136 | 136 | |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | - public function testcache_sugar_vcal() |
|
141 | - { |
|
142 | - $vcal = new vCal(); |
|
143 | - $user_focus = new User("1"); |
|
140 | + public function testcache_sugar_vcal() |
|
141 | + { |
|
142 | + $vcal = new vCal(); |
|
143 | + $user_focus = new User("1"); |
|
144 | 144 | |
145 | - //execute the method and test if it works and does not throws an exception. |
|
146 | - try { |
|
147 | - $vcal->cache_sugar_vcal($user_focus); |
|
148 | - $this->assertTrue(true); |
|
149 | - } |
|
150 | - catch (Exception $e) { |
|
151 | - $this->fail(); |
|
152 | - } |
|
145 | + //execute the method and test if it works and does not throws an exception. |
|
146 | + try { |
|
147 | + $vcal->cache_sugar_vcal($user_focus); |
|
148 | + $this->assertTrue(true); |
|
149 | + } |
|
150 | + catch (Exception $e) { |
|
151 | + $this->fail(); |
|
152 | + } |
|
153 | 153 | |
154 | - } |
|
154 | + } |
|
155 | 155 | |
156 | 156 | |
157 | - public function testcache_sugar_vcal_freebusy() |
|
158 | - { |
|
159 | - $vcal = new vCal(); |
|
160 | - $user_focus = new User("1"); |
|
157 | + public function testcache_sugar_vcal_freebusy() |
|
158 | + { |
|
159 | + $vcal = new vCal(); |
|
160 | + $user_focus = new User("1"); |
|
161 | 161 | |
162 | - //execute the method and test if it works and does not throws an exception. |
|
163 | - try { |
|
164 | - $vcal->cache_sugar_vcal_freebusy($user_focus); |
|
165 | - $this->assertTrue(true); |
|
166 | - } |
|
167 | - catch (Exception $e) { |
|
168 | - $this->fail(); |
|
169 | - } |
|
162 | + //execute the method and test if it works and does not throws an exception. |
|
163 | + try { |
|
164 | + $vcal->cache_sugar_vcal_freebusy($user_focus); |
|
165 | + $this->assertTrue(true); |
|
166 | + } |
|
167 | + catch (Exception $e) { |
|
168 | + $this->fail(); |
|
169 | + } |
|
170 | 170 | |
171 | - } |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - public function testfold_ical_lines() |
|
175 | - { |
|
174 | + public function testfold_ical_lines() |
|
175 | + { |
|
176 | 176 | |
177 | - //test with short strings |
|
178 | - $result = vCal::fold_ical_lines("testkey","testvalue"); |
|
179 | - $this->assertEquals("testkey:testvalue",$result); |
|
177 | + //test with short strings |
|
178 | + $result = vCal::fold_ical_lines("testkey","testvalue"); |
|
179 | + $this->assertEquals("testkey:testvalue",$result); |
|
180 | 180 | |
181 | 181 | |
182 | - //test with longer strings |
|
183 | - $expected = "testkey11111111111111111111111111111111111111111111111111111111111111111111\r\n 11111111111111111111111111111111:testvalue11111111111111111111111111111111\r\n 11111111111111111111111111111111111111111111111111111111111111111111"; |
|
184 | - $result = vCal::fold_ical_lines("testkey" . str_repeat("1",100),"testvalue" . str_repeat("1",100)); |
|
185 | - $this->assertEquals(); |
|
182 | + //test with longer strings |
|
183 | + $expected = "testkey11111111111111111111111111111111111111111111111111111111111111111111\r\n 11111111111111111111111111111111:testvalue11111111111111111111111111111111\r\n 11111111111111111111111111111111111111111111111111111111111111111111"; |
|
184 | + $result = vCal::fold_ical_lines("testkey" . str_repeat("1",100),"testvalue" . str_repeat("1",100)); |
|
185 | + $this->assertEquals(); |
|
186 | 186 | |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - public function testcreate_ical_array_from_string() |
|
191 | - { |
|
190 | + public function testcreate_ical_array_from_string() |
|
191 | + { |
|
192 | 192 | |
193 | - $iCalString = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\nDTSTART:2016-01-09 00:00:00\r\nDTEND:2016-03-09 00:00:00\r\nDTSTAMP:2016-01-10 11:07:15\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
194 | - $expected = array( |
|
195 | - array ( 'BEGIN','VCALENDAR'), |
|
196 | - array ( 'VERSION','2.0'), |
|
197 | - array ( 'PRODID','-//SugarCRM//SugarCRM Calendar//EN'), |
|
198 | - array ( 'BEGIN', 'VFREEBUSY' ), |
|
199 | - array ( 'ORGANIZER;CN= ', 'VFREEBUSY' ), |
|
200 | - array ( 'DTSTART', '2016-01-09 00:00:00' ), |
|
201 | - array ( 'DTEND', '2016-03-09 00:00:00' ), |
|
202 | - array ( 'DTSTAMP', '2016-01-10 11:07:15' ), |
|
203 | - array ( 'END', 'VFREEBUSY' ), |
|
204 | - array ( 'END', 'VCALENDAR' ), |
|
205 | - ); |
|
206 | - $actual = vCal::create_ical_array_from_string($iCalString); |
|
207 | - $this->assertSame($expected, $actual ); |
|
193 | + $iCalString = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\nDTSTART:2016-01-09 00:00:00\r\nDTEND:2016-03-09 00:00:00\r\nDTSTAMP:2016-01-10 11:07:15\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
194 | + $expected = array( |
|
195 | + array ( 'BEGIN','VCALENDAR'), |
|
196 | + array ( 'VERSION','2.0'), |
|
197 | + array ( 'PRODID','-//SugarCRM//SugarCRM Calendar//EN'), |
|
198 | + array ( 'BEGIN', 'VFREEBUSY' ), |
|
199 | + array ( 'ORGANIZER;CN= ', 'VFREEBUSY' ), |
|
200 | + array ( 'DTSTART', '2016-01-09 00:00:00' ), |
|
201 | + array ( 'DTEND', '2016-03-09 00:00:00' ), |
|
202 | + array ( 'DTSTAMP', '2016-01-10 11:07:15' ), |
|
203 | + array ( 'END', 'VFREEBUSY' ), |
|
204 | + array ( 'END', 'VCALENDAR' ), |
|
205 | + ); |
|
206 | + $actual = vCal::create_ical_array_from_string($iCalString); |
|
207 | + $this->assertSame($expected, $actual ); |
|
208 | 208 | |
209 | - } |
|
209 | + } |
|
210 | 210 | |
211 | 211 | |
212 | - public function testcreate_ical_string_from_array() |
|
213 | - { |
|
212 | + public function testcreate_ical_string_from_array() |
|
213 | + { |
|
214 | 214 | |
215 | - $expected = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\nDTSTART:2016-01-09 00:00:00\r\nDTEND:2016-03-09 00:00:00\r\nDTSTAMP:2016-01-10 11:07:15\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
216 | - $iCalArray = array( |
|
217 | - array ( 'BEGIN','VCALENDAR'), |
|
218 | - array ( 'VERSION','2.0'), |
|
219 | - array ( 'PRODID','-//SugarCRM//SugarCRM Calendar//EN'), |
|
220 | - array ( 'BEGIN', 'VFREEBUSY' ), |
|
221 | - array ( 'ORGANIZER;CN= ', 'VFREEBUSY' ), |
|
222 | - array ( 'DTSTART', '2016-01-09 00:00:00' ), |
|
223 | - array ( 'DTEND', '2016-03-09 00:00:00' ), |
|
224 | - array ( 'DTSTAMP', '2016-01-10 11:07:15' ), |
|
225 | - array ( 'END', 'VFREEBUSY' ), |
|
226 | - array ( 'END', 'VCALENDAR' ), |
|
227 | - ); |
|
228 | - $actual = vCal::create_ical_string_from_array($iCalArray); |
|
229 | - $this->assertSame($expected, $actual ); |
|
215 | + $expected = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VFREEBUSY\r\nORGANIZER;CN= :VFREEBUSY\r\nDTSTART:2016-01-09 00:00:00\r\nDTEND:2016-03-09 00:00:00\r\nDTSTAMP:2016-01-10 11:07:15\r\nEND:VFREEBUSY\r\nEND:VCALENDAR\r\n"; |
|
216 | + $iCalArray = array( |
|
217 | + array ( 'BEGIN','VCALENDAR'), |
|
218 | + array ( 'VERSION','2.0'), |
|
219 | + array ( 'PRODID','-//SugarCRM//SugarCRM Calendar//EN'), |
|
220 | + array ( 'BEGIN', 'VFREEBUSY' ), |
|
221 | + array ( 'ORGANIZER;CN= ', 'VFREEBUSY' ), |
|
222 | + array ( 'DTSTART', '2016-01-09 00:00:00' ), |
|
223 | + array ( 'DTEND', '2016-03-09 00:00:00' ), |
|
224 | + array ( 'DTSTAMP', '2016-01-10 11:07:15' ), |
|
225 | + array ( 'END', 'VFREEBUSY' ), |
|
226 | + array ( 'END', 'VCALENDAR' ), |
|
227 | + ); |
|
228 | + $actual = vCal::create_ical_string_from_array($iCalArray); |
|
229 | + $this->assertSame($expected, $actual ); |
|
230 | 230 | |
231 | - } |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - public function testescape_ical_chars() |
|
235 | - { |
|
236 | - $this->assertSame('',vCal::escape_ical_chars('')); |
|
237 | - $this->assertSame('\;\,',vCal::escape_ical_chars(';,')); |
|
238 | - } |
|
234 | + public function testescape_ical_chars() |
|
235 | + { |
|
236 | + $this->assertSame('',vCal::escape_ical_chars('')); |
|
237 | + $this->assertSame('\;\,',vCal::escape_ical_chars(';,')); |
|
238 | + } |
|
239 | 239 | |
240 | 240 | |
241 | - public function testunescape_ical_chars() |
|
242 | - { |
|
243 | - $this->assertSame('',vCal::unescape_ical_chars('')); |
|
244 | - $this->assertSame("; , \\", vCal::unescape_ical_chars('\\; \\, \\\\')); |
|
245 | - } |
|
241 | + public function testunescape_ical_chars() |
|
242 | + { |
|
243 | + $this->assertSame('',vCal::unescape_ical_chars('')); |
|
244 | + $this->assertSame("; , \\", vCal::unescape_ical_chars('\\; \\, \\\\')); |
|
245 | + } |
|
246 | 246 | |
247 | 247 | |
248 | - public function testget_ical_event(){ |
|
248 | + public function testget_ical_event(){ |
|
249 | 249 | |
250 | - $user = new User(1); |
|
251 | - $meeting = new Meeting(); |
|
250 | + $user = new User(1); |
|
251 | + $meeting = new Meeting(); |
|
252 | 252 | |
253 | - $meeting->id = 1; |
|
254 | - $meeting->date_start = "2016-02-11 17:30:00"; |
|
255 | - $meeting->date_end = "2016-02-11 17:30:00"; |
|
256 | - $meeting->name = "test"; |
|
257 | - $meeting->location = "test location"; |
|
258 | - $meeting->description = "test description"; |
|
253 | + $meeting->id = 1; |
|
254 | + $meeting->date_start = "2016-02-11 17:30:00"; |
|
255 | + $meeting->date_end = "2016-02-11 17:30:00"; |
|
256 | + $meeting->name = "test"; |
|
257 | + $meeting->location = "test location"; |
|
258 | + $meeting->description = "test description"; |
|
259 | 259 | |
260 | - $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VEVENT\r\nUID:1\r\nORGANIZED;CN=:\r\nDTSTART:20160211T173000Z\r\nDTEND:20160211T173000Z\r\n"; |
|
261 | - $expectedEnd = "\r\nSUMMARY:test\r\nLOCATION:test location\r\nDESCRIPTION:test description\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; |
|
260 | + $expectedStart = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//SugarCRM//SugarCRM Calendar//EN\r\nBEGIN:VEVENT\r\nUID:1\r\nORGANIZED;CN=:\r\nDTSTART:20160211T173000Z\r\nDTEND:20160211T173000Z\r\n"; |
|
261 | + $expectedEnd = "\r\nSUMMARY:test\r\nLOCATION:test location\r\nDESCRIPTION:test description\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"; |
|
262 | 262 | |
263 | - $result = vCal::get_ical_event($meeting ,$user); |
|
263 | + $result = vCal::get_ical_event($meeting ,$user); |
|
264 | 264 | |
265 | - $this->assertStringStartsWith($expectedStart, $result); |
|
266 | - $this->assertStringEndsWith($expectedEnd, $result); |
|
265 | + $this->assertStringStartsWith($expectedStart, $result); |
|
266 | + $this->assertStringEndsWith($expectedEnd, $result); |
|
267 | 267 | |
268 | - } |
|
268 | + } |
|
269 | 269 | |
270 | 270 | } |
271 | 271 |
@@ -3,225 +3,225 @@ |
||
3 | 3 | class SugarFeedTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testSugarFeed(){ |
|
6 | + public function testSugarFeed(){ |
|
7 | 7 | |
8 | - error_reporting(E_ERROR | E_PARSE); |
|
8 | + error_reporting(E_ERROR | E_PARSE); |
|
9 | 9 | |
10 | - //execute the contructor and check for the Object type and attributes |
|
11 | - $sugarFeed = new SugarFeed(); |
|
10 | + //execute the contructor and check for the Object type and attributes |
|
11 | + $sugarFeed = new SugarFeed(); |
|
12 | 12 | |
13 | - $this->assertInstanceOf('SugarFeed',$sugarFeed); |
|
14 | - $this->assertInstanceOf('Basic',$sugarFeed); |
|
15 | - $this->assertInstanceOf('SugarBean',$sugarFeed); |
|
13 | + $this->assertInstanceOf('SugarFeed',$sugarFeed); |
|
14 | + $this->assertInstanceOf('Basic',$sugarFeed); |
|
15 | + $this->assertInstanceOf('SugarBean',$sugarFeed); |
|
16 | 16 | |
17 | - $this->assertAttributeEquals('sugarfeed', 'table_name', $sugarFeed); |
|
18 | - $this->assertAttributeEquals('SugarFeed', 'module_dir', $sugarFeed); |
|
19 | - $this->assertAttributeEquals('SugarFeed', 'object_name', $sugarFeed); |
|
17 | + $this->assertAttributeEquals('sugarfeed', 'table_name', $sugarFeed); |
|
18 | + $this->assertAttributeEquals('SugarFeed', 'module_dir', $sugarFeed); |
|
19 | + $this->assertAttributeEquals('SugarFeed', 'object_name', $sugarFeed); |
|
20 | 20 | |
21 | - $this->assertAttributeEquals(true, 'new_schema', $sugarFeed); |
|
22 | - $this->assertAttributeEquals(false, 'importable', $sugarFeed); |
|
21 | + $this->assertAttributeEquals(true, 'new_schema', $sugarFeed); |
|
22 | + $this->assertAttributeEquals(false, 'importable', $sugarFeed); |
|
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - public function testactivateAndDisableModuleFeed() { |
|
26 | + public function testactivateAndDisableModuleFeed() { |
|
27 | 27 | |
28 | - $admin = new Administration(); |
|
28 | + $admin = new Administration(); |
|
29 | 29 | |
30 | - //test activateModuleFeed method |
|
31 | - SugarFeed::activateModuleFeed('Accounts'); |
|
32 | - $admin->retrieveSettings('sugarfeed'); |
|
33 | - $this->assertEquals(1,$admin->settings['sugarfeed_module_Accounts']); |
|
30 | + //test activateModuleFeed method |
|
31 | + SugarFeed::activateModuleFeed('Accounts'); |
|
32 | + $admin->retrieveSettings('sugarfeed'); |
|
33 | + $this->assertEquals(1,$admin->settings['sugarfeed_module_Accounts']); |
|
34 | 34 | |
35 | 35 | |
36 | - //test disableModuleFeed method |
|
37 | - SugarFeed::disableModuleFeed('Accounts'); |
|
38 | - $admin->retrieveSettings('sugarfeed'); |
|
39 | - $this->assertEquals(0, $admin->settings['sugarfeed_module_Accounts']); |
|
36 | + //test disableModuleFeed method |
|
37 | + SugarFeed::disableModuleFeed('Accounts'); |
|
38 | + $admin->retrieveSettings('sugarfeed'); |
|
39 | + $this->assertEquals(0, $admin->settings['sugarfeed_module_Accounts']); |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | 44 | public function testflushBackendCache() { |
45 | 45 | |
46 | - //execute the method and test if it works and does not throws an exception. |
|
47 | - try { |
|
48 | - SugarFeed::flushBackendCache(); |
|
49 | - $this->assertTrue(true); |
|
50 | - } |
|
51 | - catch (Exception $e) { |
|
52 | - $this->fail(); |
|
53 | - } |
|
46 | + //execute the method and test if it works and does not throws an exception. |
|
47 | + try { |
|
48 | + SugarFeed::flushBackendCache(); |
|
49 | + $this->assertTrue(true); |
|
50 | + } |
|
51 | + catch (Exception $e) { |
|
52 | + $this->fail(); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | 57 | |
58 | 58 | public function testgetModuleFeedFiles( ) { |
59 | 59 | |
60 | - //test with invalid module |
|
61 | - $expected = array(); |
|
62 | - $result = SugarFeed::getModuleFeedFiles('Accounts'); |
|
63 | - $this->assertEquals($expected, $result); |
|
60 | + //test with invalid module |
|
61 | + $expected = array(); |
|
62 | + $result = SugarFeed::getModuleFeedFiles('Accounts'); |
|
63 | + $this->assertEquals($expected, $result); |
|
64 | 64 | |
65 | 65 | |
66 | - //test with valid module |
|
67 | - $expected = array( "CaseFeed.php"=> "modules/Cases/SugarFeeds/CaseFeed.php"); |
|
68 | - $result = SugarFeed::getModuleFeedFiles('Cases'); |
|
69 | - $this->assertEquals($expected, $result); |
|
66 | + //test with valid module |
|
67 | + $expected = array( "CaseFeed.php"=> "modules/Cases/SugarFeeds/CaseFeed.php"); |
|
68 | + $result = SugarFeed::getModuleFeedFiles('Cases'); |
|
69 | + $this->assertEquals($expected, $result); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function testgetActiveFeedModules( ) { |
74 | 74 | |
75 | - $result = SugarFeed::getActiveFeedModules(); |
|
75 | + $result = SugarFeed::getActiveFeedModules(); |
|
76 | 76 | |
77 | - $expected = array ( |
|
78 | - 'UserFeed' => 'UserFeed', |
|
79 | - 'Cases' => 'Cases', |
|
80 | - 'Contacts' => 'Contacts', |
|
81 | - 'Leads' => 'Leads', |
|
82 | - 'Opportunities' => 'Opportunities', |
|
83 | - ); |
|
77 | + $expected = array ( |
|
78 | + 'UserFeed' => 'UserFeed', |
|
79 | + 'Cases' => 'Cases', |
|
80 | + 'Contacts' => 'Contacts', |
|
81 | + 'Leads' => 'Leads', |
|
82 | + 'Opportunities' => 'Opportunities', |
|
83 | + ); |
|
84 | 84 | |
85 | - $this->assertEquals($expected, $result); |
|
85 | + $this->assertEquals($expected, $result); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | public function testgetAllFeedModules( ) { |
90 | 90 | |
91 | - $result = SugarFeed::getAllFeedModules(); |
|
92 | - $expected = array ( |
|
93 | - 'UserFeed' => 'UserFeed', |
|
94 | - 'Cases' => 'Cases', |
|
95 | - 'Contacts' => 'Contacts', |
|
96 | - 'Leads' => 'Leads', |
|
97 | - 'Opportunities' => 'Opportunities', |
|
98 | - ); |
|
91 | + $result = SugarFeed::getAllFeedModules(); |
|
92 | + $expected = array ( |
|
93 | + 'UserFeed' => 'UserFeed', |
|
94 | + 'Cases' => 'Cases', |
|
95 | + 'Contacts' => 'Contacts', |
|
96 | + 'Leads' => 'Leads', |
|
97 | + 'Opportunities' => 'Opportunities', |
|
98 | + ); |
|
99 | 99 | |
100 | - $this->assertEquals($expected, $result); |
|
100 | + $this->assertEquals($expected, $result); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
104 | 104 | |
105 | 105 | public function testpushFeed2() { |
106 | 106 | |
107 | - $lead = new Lead(); |
|
108 | - $lead->id = 1; |
|
109 | - $lead->assigned_user_id = 1; |
|
107 | + $lead = new Lead(); |
|
108 | + $lead->id = 1; |
|
109 | + $lead->assigned_user_id = 1; |
|
110 | 110 | |
111 | - SugarFeed::pushFeed2("some text 2", $lead,'Link', 'some url'); |
|
111 | + SugarFeed::pushFeed2("some text 2", $lead,'Link', 'some url'); |
|
112 | 112 | |
113 | - //retrieve newly created bean |
|
114 | - $sugarFeed = new SugarFeed(); |
|
115 | - $result = $sugarFeed->retrieve_by_string_fields(array("related_id" => '1', 'related_module'=> 'Leads')); |
|
113 | + //retrieve newly created bean |
|
114 | + $sugarFeed = new SugarFeed(); |
|
115 | + $result = $sugarFeed->retrieve_by_string_fields(array("related_id" => '1', 'related_module'=> 'Leads')); |
|
116 | 116 | |
117 | - //test for record ID to verify that record is saved |
|
118 | - $this->assertTrue(isset($sugarFeed->id)); |
|
119 | - $this->assertEquals(36, strlen($sugarFeed->id)); |
|
117 | + //test for record ID to verify that record is saved |
|
118 | + $this->assertTrue(isset($sugarFeed->id)); |
|
119 | + $this->assertEquals(36, strlen($sugarFeed->id)); |
|
120 | 120 | |
121 | - //mark the record as deleted |
|
122 | - $sugarFeed->mark_deleted($sugarFeed->id); |
|
121 | + //mark the record as deleted |
|
122 | + $sugarFeed->mark_deleted($sugarFeed->id); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
126 | - public function testpushFeed(){ |
|
126 | + public function testpushFeed(){ |
|
127 | 127 | |
128 | 128 | |
129 | - SugarFeed::pushFeed("some text", 'SugarFeed', 1, 1,'Link', 'some url'); |
|
129 | + SugarFeed::pushFeed("some text", 'SugarFeed', 1, 1,'Link', 'some url'); |
|
130 | 130 | |
131 | 131 | |
132 | - //retrieve newly created bean |
|
133 | - $sugarFeed = new SugarFeed(); |
|
134 | - $result = $sugarFeed->retrieve_by_string_fields(array("related_id" => '1', 'related_module'=> 'SugarFeed')); |
|
132 | + //retrieve newly created bean |
|
133 | + $sugarFeed = new SugarFeed(); |
|
134 | + $result = $sugarFeed->retrieve_by_string_fields(array("related_id" => '1', 'related_module'=> 'SugarFeed')); |
|
135 | 135 | |
136 | 136 | |
137 | - //test for record ID to verify that record is saved |
|
138 | - $this->assertTrue(isset($sugarFeed->id)); |
|
139 | - $this->assertEquals(36, strlen($sugarFeed->id)); |
|
137 | + //test for record ID to verify that record is saved |
|
138 | + $this->assertTrue(isset($sugarFeed->id)); |
|
139 | + $this->assertEquals(36, strlen($sugarFeed->id)); |
|
140 | 140 | |
141 | 141 | |
142 | - //test fetchReplies method |
|
143 | - $this->fetchReplies(); |
|
142 | + //test fetchReplies method |
|
143 | + $this->fetchReplies(); |
|
144 | 144 | |
145 | 145 | |
146 | - //mark the record as deleted |
|
147 | - $sugarFeed->mark_deleted($sugarFeed->id); |
|
146 | + //mark the record as deleted |
|
147 | + $sugarFeed->mark_deleted($sugarFeed->id); |
|
148 | 148 | |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | - public function fetchReplies() { |
|
151 | + public function fetchReplies() { |
|
152 | 152 | |
153 | - $sugarFeed = new SugarFeed(); |
|
153 | + $sugarFeed = new SugarFeed(); |
|
154 | 154 | |
155 | - $actual = $sugarFeed->fetchReplies(array('ID'=>'1')); |
|
156 | - $this->assertGreaterThan(0,strlen($actual)); |
|
155 | + $actual = $sugarFeed->fetchReplies(array('ID'=>'1')); |
|
156 | + $this->assertGreaterThan(0,strlen($actual)); |
|
157 | 157 | |
158 | - } |
|
158 | + } |
|
159 | 159 | |
160 | 160 | public function testgetLinkTypes() { |
161 | 161 | |
162 | - $result = SugarFeed::getLinkTypes(); |
|
162 | + $result = SugarFeed::getLinkTypes(); |
|
163 | 163 | |
164 | - $expected = array ( |
|
165 | - 'Image' => 'Image', |
|
166 | - 'Link' => 'Link', |
|
167 | - 'YouTube' => 'YouTube', |
|
168 | - ); |
|
169 | - $this->assertEquals($expected, $result); |
|
164 | + $expected = array ( |
|
165 | + 'Image' => 'Image', |
|
166 | + 'Link' => 'Link', |
|
167 | + 'YouTube' => 'YouTube', |
|
168 | + ); |
|
169 | + $this->assertEquals($expected, $result); |
|
170 | 170 | |
171 | 171 | } |
172 | 172 | |
173 | 173 | public function testgetLinkClass( ) { |
174 | 174 | |
175 | - //test with invalid LinkType |
|
176 | - $result = SugarFeed::getLinkClass('test'); |
|
177 | - $this->assertEquals(false, $result); |
|
175 | + //test with invalid LinkType |
|
176 | + $result = SugarFeed::getLinkClass('test'); |
|
177 | + $this->assertEquals(false, $result); |
|
178 | 178 | |
179 | - //test with LinkType Image |
|
180 | - $result = SugarFeed::getLinkClass('Image'); |
|
181 | - $this->assertInstanceOf('FeedLinkHandlerImage',$result); |
|
179 | + //test with LinkType Image |
|
180 | + $result = SugarFeed::getLinkClass('Image'); |
|
181 | + $this->assertInstanceOf('FeedLinkHandlerImage',$result); |
|
182 | 182 | |
183 | - //test with LinkType Link |
|
184 | - $result = SugarFeed::getLinkClass('Link'); |
|
185 | - $this->assertInstanceOf('FeedLinkHandlerLink',$result); |
|
183 | + //test with LinkType Link |
|
184 | + $result = SugarFeed::getLinkClass('Link'); |
|
185 | + $this->assertInstanceOf('FeedLinkHandlerLink',$result); |
|
186 | 186 | |
187 | - //test with LinkType YouTube |
|
188 | - $result = SugarFeed::getLinkClass('YouTube'); |
|
189 | - $this->assertInstanceOf('FeedLinkHandlerYoutube',$result); |
|
187 | + //test with LinkType YouTube |
|
188 | + $result = SugarFeed::getLinkClass('YouTube'); |
|
189 | + $this->assertInstanceOf('FeedLinkHandlerYoutube',$result); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
193 | - public function testget_list_view_data(){ |
|
193 | + public function testget_list_view_data(){ |
|
194 | 194 | |
195 | - $sugarFeed = new SugarFeed(); |
|
195 | + $sugarFeed = new SugarFeed(); |
|
196 | 196 | |
197 | - $result = $sugarFeed->get_list_view_data(); |
|
198 | - $this->assertTrue(is_array($result)); |
|
197 | + $result = $sugarFeed->get_list_view_data(); |
|
198 | + $this->assertTrue(is_array($result)); |
|
199 | 199 | |
200 | - } |
|
200 | + } |
|
201 | 201 | |
202 | 202 | |
203 | - public function testgetTimeLapse() |
|
204 | - { |
|
205 | - $result = SugarFeed::getTimeLapse('2016-01-15 11:16:02'); |
|
206 | - $this->assertTrue(isset($result)); |
|
207 | - $this->assertGreaterThan(0, strlen($result)); |
|
203 | + public function testgetTimeLapse() |
|
204 | + { |
|
205 | + $result = SugarFeed::getTimeLapse('2016-01-15 11:16:02'); |
|
206 | + $this->assertTrue(isset($result)); |
|
207 | + $this->assertGreaterThan(0, strlen($result)); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | 212 | public function testparseMessage(){ |
213 | 213 | |
214 | - //test with a string with no links |
|
215 | - $html = "some text with no urls"; |
|
216 | - $result = SugarFeed::parseMessage($html); |
|
217 | - $this->assertEquals($html ,$result); |
|
214 | + //test with a string with no links |
|
215 | + $html = "some text with no urls"; |
|
216 | + $result = SugarFeed::parseMessage($html); |
|
217 | + $this->assertEquals($html ,$result); |
|
218 | 218 | |
219 | 219 | |
220 | - //test with a string with links |
|
221 | - $html = "some text http://www.url.com with no urls"; |
|
222 | - $expected = "some text <a href='http://www.url.com' target='_blank'>http://www.url.com</a> with no urls"; |
|
223 | - $result = SugarFeed::parseMessage($html); |
|
224 | - $this->assertEquals($expected ,$result); |
|
220 | + //test with a string with links |
|
221 | + $html = "some text http://www.url.com with no urls"; |
|
222 | + $expected = "some text <a href='http://www.url.com' target='_blank'>http://www.url.com</a> with no urls"; |
|
223 | + $result = SugarFeed::parseMessage($html); |
|
224 | + $this->assertEquals($expected ,$result); |
|
225 | 225 | |
226 | 226 | } |
227 | 227 |
@@ -3,169 +3,169 @@ |
||
3 | 3 | class UserPreferenceTest extends PHPUnit_Framework_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - public function test__construct() |
|
7 | - { |
|
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $userPreference = new UserPreference(); |
|
6 | + public function test__construct() |
|
7 | + { |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $userPreference = new UserPreference(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('UserPreference',$userPreference); |
|
12 | - $this->assertInstanceOf('SugarBean',$userPreference); |
|
11 | + $this->assertInstanceOf('UserPreference',$userPreference); |
|
12 | + $this->assertInstanceOf('SugarBean',$userPreference); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('user_preferences', 'table_name', $userPreference); |
|
15 | - $this->assertAttributeEquals('UserPreferences', 'module_dir', $userPreference); |
|
16 | - $this->assertAttributeEquals('UserPreference', 'object_name', $userPreference); |
|
14 | + $this->assertAttributeEquals('user_preferences', 'table_name', $userPreference); |
|
15 | + $this->assertAttributeEquals('UserPreferences', 'module_dir', $userPreference); |
|
16 | + $this->assertAttributeEquals('UserPreference', 'object_name', $userPreference); |
|
17 | 17 | |
18 | 18 | |
19 | - $this->assertAttributeEquals(true, 'new_schema', $userPreference); |
|
20 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $userPreference); |
|
19 | + $this->assertAttributeEquals(true, 'new_schema', $userPreference); |
|
20 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $userPreference); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - public function testgetDefaultPreference( ) |
|
26 | - { |
|
27 | - global $sugar_config; |
|
25 | + public function testgetDefaultPreference( ) |
|
26 | + { |
|
27 | + global $sugar_config; |
|
28 | 28 | |
29 | - error_reporting(E_ERROR | E_PARSE); |
|
29 | + error_reporting(E_ERROR | E_PARSE); |
|
30 | 30 | |
31 | - $userPreference = new UserPreference(); |
|
31 | + $userPreference = new UserPreference(); |
|
32 | 32 | |
33 | - //test with non global category |
|
34 | - $result = $userPreference->getDefaultPreference('chartEngine', 'Home'); |
|
35 | - $this->assertEquals(null,$result); |
|
33 | + //test with non global category |
|
34 | + $result = $userPreference->getDefaultPreference('chartEngine', 'Home'); |
|
35 | + $this->assertEquals(null,$result); |
|
36 | 36 | |
37 | 37 | |
38 | - //test with default global category |
|
38 | + //test with default global category |
|
39 | 39 | |
40 | - $result = $userPreference->getDefaultPreference('chartEngine'); |
|
41 | - $this->assertEquals($sugar_config['chartEngine'] ,$result); |
|
40 | + $result = $userPreference->getDefaultPreference('chartEngine'); |
|
41 | + $this->assertEquals($sugar_config['chartEngine'] ,$result); |
|
42 | 42 | |
43 | 43 | |
44 | - $date_format = $sugar_config['datef'] != "" ? $sugar_config['datef'] : $sugar_config['default_date_format']; |
|
45 | - $result = $userPreference->getDefaultPreference('datef'); |
|
46 | - $this->assertEquals($date_format, $result); |
|
44 | + $date_format = $sugar_config['datef'] != "" ? $sugar_config['datef'] : $sugar_config['default_date_format']; |
|
45 | + $result = $userPreference->getDefaultPreference('datef'); |
|
46 | + $this->assertEquals($date_format, $result); |
|
47 | 47 | |
48 | 48 | |
49 | - $time_format = $sugar_config['timef'] != ""? $sugar_config['timef'] : $sugar_config['default_time_format']; |
|
50 | - $result = $userPreference->getDefaultPreference('timef'); |
|
51 | - $this->assertEquals($time_format , $result); |
|
49 | + $time_format = $sugar_config['timef'] != ""? $sugar_config['timef'] : $sugar_config['default_time_format']; |
|
50 | + $result = $userPreference->getDefaultPreference('timef'); |
|
51 | + $this->assertEquals($time_format , $result); |
|
52 | 52 | |
53 | 53 | |
54 | - $email_link_type = $sugar_config['email_link_type'] != "" ? $sugar_config['email_link_type'] : $sugar_config['email_default_client']; |
|
55 | - $result = $userPreference->getDefaultPreference('email_link_type'); |
|
56 | - $this->assertEquals($email_link_type , $result); |
|
54 | + $email_link_type = $sugar_config['email_link_type'] != "" ? $sugar_config['email_link_type'] : $sugar_config['email_default_client']; |
|
55 | + $result = $userPreference->getDefaultPreference('email_link_type'); |
|
56 | + $this->assertEquals($email_link_type , $result); |
|
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - public function testSetAndGetPreference() |
|
62 | - { |
|
63 | - global $sugar_config; |
|
61 | + public function testSetAndGetPreference() |
|
62 | + { |
|
63 | + global $sugar_config; |
|
64 | 64 | |
65 | - $user = new User(); |
|
66 | - $user->retrieve("1"); |
|
65 | + $user = new User(); |
|
66 | + $user->retrieve("1"); |
|
67 | 67 | |
68 | - $userPreference = new UserPreference($user); |
|
68 | + $userPreference = new UserPreference($user); |
|
69 | 69 | |
70 | - //test setPreference method |
|
71 | - $userPreference->setPreference("test","test val","test_category"); |
|
72 | - $result = $_SESSION[$user->user_name.'_PREFERENCES']['test_category']['test']; |
|
73 | - $this->assertEquals("test val", $result); |
|
70 | + //test setPreference method |
|
71 | + $userPreference->setPreference("test","test val","test_category"); |
|
72 | + $result = $_SESSION[$user->user_name.'_PREFERENCES']['test_category']['test']; |
|
73 | + $this->assertEquals("test val", $result); |
|
74 | 74 | |
75 | 75 | |
76 | - //test getPreference method |
|
77 | - $result = $userPreference->getPreference("test", "test_category"); |
|
78 | - $this->assertEquals("test val", $result); |
|
76 | + //test getPreference method |
|
77 | + $result = $userPreference->getPreference("test", "test_category"); |
|
78 | + $this->assertEquals("test val", $result); |
|
79 | 79 | |
80 | - $result = $userPreference->getPreference("chartEngine"); |
|
81 | - $this->assertEquals($sugar_config['chartEngine'], $result); |
|
80 | + $result = $userPreference->getPreference("chartEngine"); |
|
81 | + $this->assertEquals($sugar_config['chartEngine'], $result); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - public function testloadPreferences( ) |
|
87 | - { |
|
88 | - $user = new User(); |
|
89 | - $user->retrieve("1"); |
|
86 | + public function testloadPreferences( ) |
|
87 | + { |
|
88 | + $user = new User(); |
|
89 | + $user->retrieve("1"); |
|
90 | 90 | |
91 | - $userPreference = new UserPreference($user); |
|
91 | + $userPreference = new UserPreference($user); |
|
92 | 92 | |
93 | - $result = $userPreference->loadPreferences(); |
|
93 | + $result = $userPreference->loadPreferences(); |
|
94 | 94 | |
95 | - $this->assertEquals(false, $result); |
|
96 | - } |
|
95 | + $this->assertEquals(false, $result); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | - public function testreloadPreferences() |
|
100 | - { |
|
99 | + public function testreloadPreferences() |
|
100 | + { |
|
101 | 101 | |
102 | - $user = new User(); |
|
103 | - $user->retrieve("1"); |
|
102 | + $user = new User(); |
|
103 | + $user->retrieve("1"); |
|
104 | 104 | |
105 | - $userPreference = new UserPreference($user); |
|
105 | + $userPreference = new UserPreference($user); |
|
106 | 106 | |
107 | - $result = $userPreference->reloadPreferences(); |
|
108 | - $this->assertEquals(false, $result); |
|
107 | + $result = $userPreference->reloadPreferences(); |
|
108 | + $this->assertEquals(false, $result); |
|
109 | 109 | |
110 | - } |
|
110 | + } |
|
111 | 111 | |
112 | 112 | |
113 | - public function testgetUserDateTimePreferences() |
|
114 | - { |
|
113 | + public function testgetUserDateTimePreferences() |
|
114 | + { |
|
115 | 115 | |
116 | - $user = new User(); |
|
117 | - $user->retrieve("1"); |
|
116 | + $user = new User(); |
|
117 | + $user->retrieve("1"); |
|
118 | 118 | |
119 | - $userPreference = new UserPreference($user); |
|
119 | + $userPreference = new UserPreference($user); |
|
120 | 120 | |
121 | - $result = $userPreference->getUserDateTimePreferences(); |
|
122 | - $this->assertTrue(is_array($result)); |
|
121 | + $result = $userPreference->getUserDateTimePreferences(); |
|
122 | + $this->assertTrue(is_array($result)); |
|
123 | 123 | |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | - public function testSavePreferencesToDBAndResetPreferences( ) |
|
128 | - { |
|
129 | - $user = new User(); |
|
130 | - $user->retrieve("1"); |
|
127 | + public function testSavePreferencesToDBAndResetPreferences( ) |
|
128 | + { |
|
129 | + $user = new User(); |
|
130 | + $user->retrieve("1"); |
|
131 | 131 | |
132 | - $userPreference = new UserPreference($user); |
|
132 | + $userPreference = new UserPreference($user); |
|
133 | 133 | |
134 | - //create a Preference record, save it to DB |
|
135 | - $userPreference->setPreference("test","test val","test_category"); |
|
136 | - $userPreference->savePreferencesToDB(); |
|
134 | + //create a Preference record, save it to DB |
|
135 | + $userPreference->setPreference("test","test val","test_category"); |
|
136 | + $userPreference->savePreferencesToDB(); |
|
137 | 137 | |
138 | 138 | |
139 | - //retrieve it back and verify |
|
140 | - $result = $userPreference->retrieve_by_string_fields(array( |
|
141 | - 'assigned_user_id' => $user->id, |
|
142 | - 'category' => 'test_category', |
|
143 | - )); |
|
144 | - $this->assertTrue(isset($result->id)); |
|
139 | + //retrieve it back and verify |
|
140 | + $result = $userPreference->retrieve_by_string_fields(array( |
|
141 | + 'assigned_user_id' => $user->id, |
|
142 | + 'category' => 'test_category', |
|
143 | + )); |
|
144 | + $this->assertTrue(isset($result->id)); |
|
145 | 145 | |
146 | 146 | |
147 | - //reset the preferences and verify that it is deleted |
|
148 | - $userPreference->resetPreferences(); |
|
149 | - $result = $userPreference->retrieve_by_string_fields(array( |
|
150 | - 'assigned_user_id' => $user->id, |
|
151 | - 'category' => 'test_category', |
|
152 | - )); |
|
153 | - $this->assertEquals(null,$result); |
|
147 | + //reset the preferences and verify that it is deleted |
|
148 | + $userPreference->resetPreferences(); |
|
149 | + $result = $userPreference->retrieve_by_string_fields(array( |
|
150 | + 'assigned_user_id' => $user->id, |
|
151 | + 'category' => 'test_category', |
|
152 | + )); |
|
153 | + $this->assertEquals(null,$result); |
|
154 | 154 | |
155 | - } |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - public function testupdateAllUserPrefs( ) |
|
159 | - { |
|
160 | - global $current_user; |
|
158 | + public function testupdateAllUserPrefs( ) |
|
159 | + { |
|
160 | + global $current_user; |
|
161 | 161 | |
162 | - $current_user = new User(); |
|
163 | - $current_user->retrieve("1"); |
|
162 | + $current_user = new User(); |
|
163 | + $current_user->retrieve("1"); |
|
164 | 164 | |
165 | - //UserPreference::updateAllUserPrefs("test","test val"); |
|
165 | + //UserPreference::updateAllUserPrefs("test","test val"); |
|
166 | 166 | |
167 | - $this->markTestIncomplete('Multiple errors in method: Unknown column user_preferences in field list'); |
|
167 | + $this->markTestIncomplete('Multiple errors in method: Unknown column user_preferences in field list'); |
|
168 | 168 | |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | 171 | } |
@@ -3,311 +3,311 @@ |
||
3 | 3 | class OpportunityTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testOpportunity() { |
|
6 | + public function testOpportunity() { |
|
7 | 7 | |
8 | 8 | |
9 | - //execute the contructor and check for the Object type and attributes |
|
10 | - $opportunity = new Opportunity(); |
|
9 | + //execute the contructor and check for the Object type and attributes |
|
10 | + $opportunity = new Opportunity(); |
|
11 | 11 | |
12 | - $this->assertInstanceOf('Opportunity',$opportunity); |
|
13 | - $this->assertInstanceOf('SugarBean',$opportunity); |
|
12 | + $this->assertInstanceOf('Opportunity',$opportunity); |
|
13 | + $this->assertInstanceOf('SugarBean',$opportunity); |
|
14 | 14 | |
15 | 15 | |
16 | - $this->assertAttributeEquals('opportunities', 'table_name', $opportunity); |
|
17 | - $this->assertAttributeEquals('accounts_opportunities', 'rel_account_table', $opportunity); |
|
18 | - $this->assertAttributeEquals('opportunities_contacts', 'rel_contact_table', $opportunity); |
|
19 | - $this->assertAttributeEquals('Opportunities', 'module_dir', $opportunity); |
|
20 | - $this->assertAttributeEquals('Opportunity', 'object_name', $opportunity); |
|
16 | + $this->assertAttributeEquals('opportunities', 'table_name', $opportunity); |
|
17 | + $this->assertAttributeEquals('accounts_opportunities', 'rel_account_table', $opportunity); |
|
18 | + $this->assertAttributeEquals('opportunities_contacts', 'rel_contact_table', $opportunity); |
|
19 | + $this->assertAttributeEquals('Opportunities', 'module_dir', $opportunity); |
|
20 | + $this->assertAttributeEquals('Opportunity', 'object_name', $opportunity); |
|
21 | 21 | |
22 | - $this->assertAttributeEquals(true, 'new_schema', $opportunity); |
|
23 | - $this->assertAttributeEquals(true, 'importable', $opportunity); |
|
22 | + $this->assertAttributeEquals(true, 'new_schema', $opportunity); |
|
23 | + $this->assertAttributeEquals(true, 'importable', $opportunity); |
|
24 | 24 | |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - public function testget_summary_text() { |
|
28 | + public function testget_summary_text() { |
|
29 | 29 | |
30 | - error_reporting(E_ERROR | E_PARSE); |
|
30 | + error_reporting(E_ERROR | E_PARSE); |
|
31 | 31 | |
32 | - $opportunity = new Opportunity(); |
|
32 | + $opportunity = new Opportunity(); |
|
33 | 33 | |
34 | - //test without setting name |
|
35 | - $this->assertEquals(Null,$opportunity->get_summary_text()); |
|
34 | + //test without setting name |
|
35 | + $this->assertEquals(Null,$opportunity->get_summary_text()); |
|
36 | 36 | |
37 | - //test with name set |
|
38 | - $opportunity->name = "test"; |
|
39 | - $this->assertEquals('test',$opportunity->get_summary_text()); |
|
37 | + //test with name set |
|
38 | + $opportunity->name = "test"; |
|
39 | + $this->assertEquals('test',$opportunity->get_summary_text()); |
|
40 | 40 | |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - public function testcreate_list_query(){ |
|
43 | + public function testcreate_list_query(){ |
|
44 | 44 | |
45 | - $opportunity = new Opportunity(); |
|
45 | + $opportunity = new Opportunity(); |
|
46 | 46 | |
47 | - //test with empty string params |
|
48 | - $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; |
|
49 | - $actual = $opportunity->create_list_query('',''); |
|
50 | - $this->assertSame($expected,$actual); |
|
47 | + //test with empty string params |
|
48 | + $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; |
|
49 | + $actual = $opportunity->create_list_query('',''); |
|
50 | + $this->assertSame($expected,$actual); |
|
51 | 51 | |
52 | 52 | |
53 | - //test with valid string params |
|
54 | - $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; |
|
55 | - $actual = $opportunity->create_list_query('accounts.id','accounts.name=""'); |
|
56 | - $this->assertSame($expected,$actual); |
|
53 | + //test with valid string params |
|
54 | + $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; |
|
55 | + $actual = $opportunity->create_list_query('accounts.id','accounts.name=""'); |
|
56 | + $this->assertSame($expected,$actual); |
|
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | 61 | public function testcreate_export_query(){ |
62 | 62 | |
63 | - $opportunity = new Opportunity(); |
|
63 | + $opportunity = new Opportunity(); |
|
64 | 64 | |
65 | - //test with empty string params |
|
66 | - $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; |
|
67 | - $actual = $opportunity->create_list_query('',''); |
|
68 | - $this->assertSame($expected,$actual); |
|
65 | + //test with empty string params |
|
66 | + $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY opportunities.name"; |
|
67 | + $actual = $opportunity->create_list_query('',''); |
|
68 | + $this->assertSame($expected,$actual); |
|
69 | 69 | |
70 | 70 | |
71 | - //test with valid string params |
|
72 | - $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; |
|
73 | - $actual = $opportunity->create_list_query('accounts.id','accounts.name=""'); |
|
74 | - $this->assertSame($expected,$actual); |
|
71 | + //test with valid string params |
|
72 | + $expected = "SELECT \n accounts.id as account_id,\n accounts.name as account_name,\n accounts.assigned_user_id account_id_owner,\n users.user_name as assigned_user_name ,opportunities.*\n FROM opportunities LEFT JOIN users\n ON opportunities.assigned_user_id=users.id LEFT JOIN accounts_opportunities\n ON opportunities.id=accounts_opportunities.opportunity_id\n LEFT JOIN accounts\n ON accounts_opportunities.account_id=accounts.id where (accounts.name=\"\") AND \n (accounts_opportunities.deleted is null OR accounts_opportunities.deleted=0)\n AND (accounts.deleted is null OR accounts.deleted=0)\n AND opportunities.deleted=0 ORDER BY accounts.id"; |
|
73 | + $actual = $opportunity->create_list_query('accounts.id','accounts.name=""'); |
|
74 | + $this->assertSame($expected,$actual); |
|
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | - public function testfill_in_additional_list_fields(){ |
|
78 | + public function testfill_in_additional_list_fields(){ |
|
79 | 79 | |
80 | - $opportunity = new Opportunity(); |
|
80 | + $opportunity = new Opportunity(); |
|
81 | 81 | |
82 | - //execute the method and test if it works and does not throws an exception. |
|
83 | - try { |
|
82 | + //execute the method and test if it works and does not throws an exception. |
|
83 | + try { |
|
84 | 84 | |
85 | - //test without force_load_details |
|
86 | - $opportunity->fill_in_additional_list_fields(); |
|
85 | + //test without force_load_details |
|
86 | + $opportunity->fill_in_additional_list_fields(); |
|
87 | 87 | |
88 | 88 | |
89 | - //test without force_load_details |
|
90 | - $opportunity->force_load_details = true; |
|
91 | - $opportunity->fill_in_additional_list_fields(); |
|
89 | + //test without force_load_details |
|
90 | + $opportunity->force_load_details = true; |
|
91 | + $opportunity->fill_in_additional_list_fields(); |
|
92 | 92 | |
93 | - $this->assertTrue(true); |
|
94 | - } |
|
95 | - catch (Exception $e) { |
|
96 | - $this->fail(); |
|
97 | - } |
|
93 | + $this->assertTrue(true); |
|
94 | + } |
|
95 | + catch (Exception $e) { |
|
96 | + $this->fail(); |
|
97 | + } |
|
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - public function testfill_in_additional_detail_fields(){ |
|
101 | + public function testfill_in_additional_detail_fields(){ |
|
102 | 102 | |
103 | - $opportunity = new Opportunity(); |
|
103 | + $opportunity = new Opportunity(); |
|
104 | 104 | |
105 | - //execute the method and test if it works and does not throws an exception. |
|
106 | - try { |
|
105 | + //execute the method and test if it works and does not throws an exception. |
|
106 | + try { |
|
107 | 107 | |
108 | - $opportunity->fill_in_additional_detail_fields(); |
|
109 | - $this->assertTrue(true); |
|
110 | - } |
|
111 | - catch (Exception $e) { |
|
112 | - $this->fail(); |
|
113 | - } |
|
108 | + $opportunity->fill_in_additional_detail_fields(); |
|
109 | + $this->assertTrue(true); |
|
110 | + } |
|
111 | + catch (Exception $e) { |
|
112 | + $this->fail(); |
|
113 | + } |
|
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - public function testget_contacts(){ |
|
118 | + public function testget_contacts(){ |
|
119 | 119 | |
120 | - $opportunity = new Opportunity(); |
|
120 | + $opportunity = new Opportunity(); |
|
121 | 121 | |
122 | - $result = $opportunity->get_contacts(); |
|
123 | - $this->assertTrue(is_array($result)); |
|
122 | + $result = $opportunity->get_contacts(); |
|
123 | + $this->assertTrue(is_array($result)); |
|
124 | 124 | |
125 | - } |
|
125 | + } |
|
126 | 126 | |
127 | - public function testupdate_currency_id(){ |
|
127 | + public function testupdate_currency_id(){ |
|
128 | 128 | |
129 | - $opportunity = new Opportunity(); |
|
129 | + $opportunity = new Opportunity(); |
|
130 | 130 | |
131 | - //execute the method and test if it works and does not throws an exception. |
|
132 | - try { |
|
131 | + //execute the method and test if it works and does not throws an exception. |
|
132 | + try { |
|
133 | 133 | |
134 | - $opportunity->update_currency_id(array('GBP','EUR'), 'USD'); |
|
135 | - $this->assertTrue(true); |
|
136 | - } |
|
137 | - catch (Exception $e) { |
|
138 | - $this->fail(); |
|
139 | - } |
|
134 | + $opportunity->update_currency_id(array('GBP','EUR'), 'USD'); |
|
135 | + $this->assertTrue(true); |
|
136 | + } |
|
137 | + catch (Exception $e) { |
|
138 | + $this->fail(); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - public function testget_list_view_data(){ |
|
144 | + public function testget_list_view_data(){ |
|
145 | 145 | |
146 | - $opportunity = new Opportunity(); |
|
146 | + $opportunity = new Opportunity(); |
|
147 | 147 | |
148 | - $opportunity->name = "test"; |
|
148 | + $opportunity->name = "test"; |
|
149 | 149 | |
150 | - $expected = array ( |
|
151 | - 'NAME' => 'test', |
|
152 | - 'DELETED' => 0, |
|
153 | - 'SALES_STAGE' => '', |
|
154 | - 'ENCODED_NAME' => 'test' |
|
155 | - ); |
|
150 | + $expected = array ( |
|
151 | + 'NAME' => 'test', |
|
152 | + 'DELETED' => 0, |
|
153 | + 'SALES_STAGE' => '', |
|
154 | + 'ENCODED_NAME' => 'test' |
|
155 | + ); |
|
156 | 156 | |
157 | 157 | |
158 | - $actual = $opportunity->get_list_view_data(); |
|
159 | - //$this->assertSame($expected, $actual); |
|
160 | - $this->assertEquals($expected['NAME'], $actual['NAME']); |
|
161 | - $this->assertEquals($expected['DELETED'], $actual['DELETED']); |
|
162 | - $this->assertEquals($expected['SALES_STAGE'], $actual['SALES_STAGE']); |
|
163 | - $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); |
|
158 | + $actual = $opportunity->get_list_view_data(); |
|
159 | + //$this->assertSame($expected, $actual); |
|
160 | + $this->assertEquals($expected['NAME'], $actual['NAME']); |
|
161 | + $this->assertEquals($expected['DELETED'], $actual['DELETED']); |
|
162 | + $this->assertEquals($expected['SALES_STAGE'], $actual['SALES_STAGE']); |
|
163 | + $this->assertEquals($expected['ENCODED_NAME'], $actual['ENCODED_NAME']); |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | public function testget_currency_symbol(){ |
168 | 168 | |
169 | - $opportunity = new Opportunity(); |
|
169 | + $opportunity = new Opportunity(); |
|
170 | 170 | |
171 | - //te4st without currency id |
|
172 | - $this->assertEquals('', $opportunity->get_currency_symbol()); |
|
171 | + //te4st without currency id |
|
172 | + $this->assertEquals('', $opportunity->get_currency_symbol()); |
|
173 | 173 | |
174 | 174 | |
175 | - //test with invalid currency id |
|
176 | - $opportunity->currency_id = 1; |
|
177 | - $this->assertEquals('', $opportunity->get_currency_symbol()); |
|
175 | + //test with invalid currency id |
|
176 | + $opportunity->currency_id = 1; |
|
177 | + $this->assertEquals('', $opportunity->get_currency_symbol()); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
181 | 181 | |
182 | - public function testbuild_generic_where_clause () { |
|
182 | + public function testbuild_generic_where_clause () { |
|
183 | 183 | |
184 | - $opportunity = new Opportunity(); |
|
184 | + $opportunity = new Opportunity(); |
|
185 | 185 | |
186 | - //test with empty string params |
|
187 | - $expected = "opportunities.name like '%' or accounts.name like '%'"; |
|
188 | - $actual = $opportunity->build_generic_where_clause(''); |
|
189 | - $this->assertSame($expected,$actual); |
|
186 | + //test with empty string params |
|
187 | + $expected = "opportunities.name like '%' or accounts.name like '%'"; |
|
188 | + $actual = $opportunity->build_generic_where_clause(''); |
|
189 | + $this->assertSame($expected,$actual); |
|
190 | 190 | |
191 | - } |
|
191 | + } |
|
192 | 192 | |
193 | - public function testsave(){ |
|
193 | + public function testsave(){ |
|
194 | 194 | |
195 | - $opportunity = new Opportunity(); |
|
195 | + $opportunity = new Opportunity(); |
|
196 | 196 | |
197 | - $opportunity->name = "test"; |
|
198 | - $opportunity->description ="test description"; |
|
199 | - $opportunity->sales_stage = "Value Proposition"; |
|
197 | + $opportunity->name = "test"; |
|
198 | + $opportunity->description ="test description"; |
|
199 | + $opportunity->sales_stage = "Value Proposition"; |
|
200 | 200 | |
201 | - $result = $opportunity->save(); |
|
201 | + $result = $opportunity->save(); |
|
202 | 202 | |
203 | - //test for record ID to verify that record is saved |
|
204 | - $this->assertTrue(isset($opportunity->id)); |
|
205 | - $this->assertEquals(36, strlen($opportunity->id)); |
|
206 | - $this->assertEquals(-99, $opportunity->currency_id); |
|
207 | - $this->assertEquals(30, $opportunity->probability); |
|
203 | + //test for record ID to verify that record is saved |
|
204 | + $this->assertTrue(isset($opportunity->id)); |
|
205 | + $this->assertEquals(36, strlen($opportunity->id)); |
|
206 | + $this->assertEquals(-99, $opportunity->currency_id); |
|
207 | + $this->assertEquals(30, $opportunity->probability); |
|
208 | 208 | |
209 | 209 | |
210 | - //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
211 | - $opportunity->mark_deleted($opportunity->id); |
|
212 | - $result = $opportunity->retrieve($opportunity->id); |
|
213 | - $this->assertEquals(null,$result); |
|
210 | + //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
211 | + $opportunity->mark_deleted($opportunity->id); |
|
212 | + $result = $opportunity->retrieve($opportunity->id); |
|
213 | + $this->assertEquals(null,$result); |
|
214 | 214 | |
215 | - } |
|
215 | + } |
|
216 | 216 | |
217 | - public function testsave_relationship_changes(){ |
|
217 | + public function testsave_relationship_changes(){ |
|
218 | 218 | |
219 | - $opportunity = new Opportunity(); |
|
220 | - $opportunity->account_id = 1; |
|
219 | + $opportunity = new Opportunity(); |
|
220 | + $opportunity->account_id = 1; |
|
221 | 221 | |
222 | - try { |
|
223 | - $opportunity->save_relationship_changes(true); |
|
224 | - $this->assertTrue(true); |
|
225 | - } |
|
226 | - catch (Exception $e) { |
|
227 | - $this->fail(); |
|
228 | - } |
|
222 | + try { |
|
223 | + $opportunity->save_relationship_changes(true); |
|
224 | + $this->assertTrue(true); |
|
225 | + } |
|
226 | + catch (Exception $e) { |
|
227 | + $this->fail(); |
|
228 | + } |
|
229 | 229 | |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - public function testset_opportunity_contact_relationship(){ |
|
232 | + public function testset_opportunity_contact_relationship(){ |
|
233 | 233 | |
234 | - $opportunity = new Opportunity(); |
|
234 | + $opportunity = new Opportunity(); |
|
235 | 235 | |
236 | - try { |
|
237 | - $opportunity->set_opportunity_contact_relationship("1"); |
|
238 | - $this->assertTrue(true); |
|
239 | - } |
|
240 | - catch (Exception $e) { |
|
241 | - $this->fail(); |
|
242 | - } |
|
236 | + try { |
|
237 | + $opportunity->set_opportunity_contact_relationship("1"); |
|
238 | + $this->assertTrue(true); |
|
239 | + } |
|
240 | + catch (Exception $e) { |
|
241 | + $this->fail(); |
|
242 | + } |
|
243 | 243 | |
244 | - } |
|
244 | + } |
|
245 | 245 | |
246 | - public function testset_notification_body(){ |
|
246 | + public function testset_notification_body(){ |
|
247 | 247 | |
248 | 248 | |
249 | - $opportunity = new Opportunity(); |
|
249 | + $opportunity = new Opportunity(); |
|
250 | 250 | |
251 | - //test with attributes preset and verify template variables are set accordingly |
|
251 | + //test with attributes preset and verify template variables are set accordingly |
|
252 | 252 | |
253 | - $opportunity->name = "test"; |
|
254 | - $opportunity->amount ="100"; |
|
255 | - $opportunity->date_closed = "2015-02-11 17:30:00"; |
|
256 | - $opportunity->description = "tes description"; |
|
257 | - $opportunity->sales_stage = "Value Proposition"; |
|
253 | + $opportunity->name = "test"; |
|
254 | + $opportunity->amount ="100"; |
|
255 | + $opportunity->date_closed = "2015-02-11 17:30:00"; |
|
256 | + $opportunity->description = "tes description"; |
|
257 | + $opportunity->sales_stage = "Value Proposition"; |
|
258 | 258 | |
259 | - $result = $opportunity->set_notification_body(new Sugar_Smarty(), $opportunity); |
|
259 | + $result = $opportunity->set_notification_body(new Sugar_Smarty(), $opportunity); |
|
260 | 260 | |
261 | - $this->assertEquals($opportunity->name ,$result->_tpl_vars['OPPORTUNITY_NAME']); |
|
262 | - $this->assertEquals($opportunity->amount ,$result->_tpl_vars['OPPORTUNITY_AMOUNT']); |
|
263 | - $this->assertEquals($opportunity->date_closed ,$result->_tpl_vars['OPPORTUNITY_CLOSEDATE']); |
|
264 | - $this->assertEquals($opportunity->sales_stage ,$result->_tpl_vars['OPPORTUNITY_STAGE']); |
|
265 | - $this->assertEquals($opportunity->description ,$result->_tpl_vars['OPPORTUNITY_DESCRIPTION']); |
|
266 | - } |
|
261 | + $this->assertEquals($opportunity->name ,$result->_tpl_vars['OPPORTUNITY_NAME']); |
|
262 | + $this->assertEquals($opportunity->amount ,$result->_tpl_vars['OPPORTUNITY_AMOUNT']); |
|
263 | + $this->assertEquals($opportunity->date_closed ,$result->_tpl_vars['OPPORTUNITY_CLOSEDATE']); |
|
264 | + $this->assertEquals($opportunity->sales_stage ,$result->_tpl_vars['OPPORTUNITY_STAGE']); |
|
265 | + $this->assertEquals($opportunity->description ,$result->_tpl_vars['OPPORTUNITY_DESCRIPTION']); |
|
266 | + } |
|
267 | 267 | |
268 | - public function testbean_implements(){ |
|
268 | + public function testbean_implements(){ |
|
269 | 269 | |
270 | - $opportunity = new Opportunity(); |
|
270 | + $opportunity = new Opportunity(); |
|
271 | 271 | |
272 | - $this->assertEquals(false, $opportunity->bean_implements('')); //test with blank value |
|
273 | - $this->assertEquals(false, $opportunity->bean_implements('test')); //test with invalid value |
|
274 | - $this->assertEquals(true, $opportunity->bean_implements('ACL')); //test with valid value |
|
272 | + $this->assertEquals(false, $opportunity->bean_implements('')); //test with blank value |
|
273 | + $this->assertEquals(false, $opportunity->bean_implements('test')); //test with invalid value |
|
274 | + $this->assertEquals(true, $opportunity->bean_implements('ACL')); //test with valid value |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - public function testlistviewACLHelper(){ |
|
278 | + public function testlistviewACLHelper(){ |
|
279 | 279 | |
280 | - $opportunity = new Opportunity(); |
|
280 | + $opportunity = new Opportunity(); |
|
281 | 281 | |
282 | - $expected = array("MAIN"=>"a", "ACCOUNT"=>"a" ); |
|
283 | - $actual = $opportunity->listviewACLHelper(); |
|
284 | - $this->assertSame($expected,$actual); |
|
282 | + $expected = array("MAIN"=>"a", "ACCOUNT"=>"a" ); |
|
283 | + $actual = $opportunity->listviewACLHelper(); |
|
284 | + $this->assertSame($expected,$actual); |
|
285 | 285 | |
286 | - } |
|
286 | + } |
|
287 | 287 | |
288 | 288 | |
289 | - public function testget_account_detail() { |
|
289 | + public function testget_account_detail() { |
|
290 | 290 | |
291 | - $opportunity = new Opportunity(); |
|
291 | + $opportunity = new Opportunity(); |
|
292 | 292 | |
293 | - $result = $opportunity->get_account_detail("1"); |
|
294 | - $this->assertTrue(is_array($result)); |
|
293 | + $result = $opportunity->get_account_detail("1"); |
|
294 | + $this->assertTrue(is_array($result)); |
|
295 | 295 | |
296 | - } |
|
296 | + } |
|
297 | 297 | |
298 | - public function testgetCurrencyType(){ |
|
298 | + public function testgetCurrencyType(){ |
|
299 | 299 | |
300 | - //execute the method and test if it works and does not throws an exception. |
|
301 | - try { |
|
302 | - getCurrencyType(); |
|
303 | - $this->assertTrue(true); |
|
304 | - } |
|
305 | - catch (Exception $e) { |
|
306 | - $this->fail(); |
|
307 | - } |
|
308 | - |
|
309 | - $this->markTestIncomplete('This method has no implementation'); |
|
310 | - } |
|
300 | + //execute the method and test if it works and does not throws an exception. |
|
301 | + try { |
|
302 | + getCurrencyType(); |
|
303 | + $this->assertTrue(true); |
|
304 | + } |
|
305 | + catch (Exception $e) { |
|
306 | + $this->fail(); |
|
307 | + } |
|
308 | + |
|
309 | + $this->markTestIncomplete('This method has no implementation'); |
|
310 | + } |
|
311 | 311 | |
312 | 312 | } |
313 | 313 |
@@ -6,39 +6,39 @@ discard block |
||
6 | 6 | |
7 | 7 | public function testCampaignTracker() |
8 | 8 | { |
9 | - error_reporting(E_ERROR | E_PARSE); |
|
9 | + error_reporting(E_ERROR | E_PARSE); |
|
10 | 10 | |
11 | - //execute the contructor and check for the Object type and attributes |
|
12 | - $campaignTracker = new CampaignTracker(); |
|
13 | - $this->assertInstanceOf('CampaignTracker',$campaignTracker); |
|
14 | - $this->assertInstanceOf('SugarBean',$campaignTracker); |
|
11 | + //execute the contructor and check for the Object type and attributes |
|
12 | + $campaignTracker = new CampaignTracker(); |
|
13 | + $this->assertInstanceOf('CampaignTracker',$campaignTracker); |
|
14 | + $this->assertInstanceOf('SugarBean',$campaignTracker); |
|
15 | 15 | |
16 | - $this->assertAttributeEquals('CampaignTrackers', 'module_dir', $campaignTracker); |
|
17 | - $this->assertAttributeEquals('CampaignTracker', 'object_name', $campaignTracker); |
|
18 | - $this->assertAttributeEquals('campaign_trkrs', 'table_name', $campaignTracker); |
|
19 | - $this->assertAttributeEquals(true, 'new_schema', $campaignTracker); |
|
16 | + $this->assertAttributeEquals('CampaignTrackers', 'module_dir', $campaignTracker); |
|
17 | + $this->assertAttributeEquals('CampaignTracker', 'object_name', $campaignTracker); |
|
18 | + $this->assertAttributeEquals('campaign_trkrs', 'table_name', $campaignTracker); |
|
19 | + $this->assertAttributeEquals(true, 'new_schema', $campaignTracker); |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
23 | 23 | public function testsave() |
24 | 24 | { |
25 | 25 | |
26 | - $campaignTracker = new CampaignTracker(); |
|
26 | + $campaignTracker = new CampaignTracker(); |
|
27 | 27 | |
28 | - $campaignTracker->tracker_name = "test"; |
|
29 | - $campaignTracker->is_optout = 1; |
|
28 | + $campaignTracker->tracker_name = "test"; |
|
29 | + $campaignTracker->is_optout = 1; |
|
30 | 30 | |
31 | - $campaignTracker->save(); |
|
31 | + $campaignTracker->save(); |
|
32 | 32 | |
33 | - //test for record ID to verify that record is saved |
|
34 | - $this->assertTrue(isset($campaignTracker->id)); |
|
35 | - $this->assertEquals(36, strlen($campaignTracker->id)); |
|
33 | + //test for record ID to verify that record is saved |
|
34 | + $this->assertTrue(isset($campaignTracker->id)); |
|
35 | + $this->assertEquals(36, strlen($campaignTracker->id)); |
|
36 | 36 | |
37 | 37 | |
38 | - //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
39 | - $campaignTracker->mark_deleted($campaignTracker->id); |
|
40 | - $result = $campaignTracker->retrieve($campaignTracker->id); |
|
41 | - $this->assertEquals(null,$result); |
|
38 | + //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
39 | + $campaignTracker->mark_deleted($campaignTracker->id); |
|
40 | + $result = $campaignTracker->retrieve($campaignTracker->id); |
|
41 | + $this->assertEquals(null,$result); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
@@ -46,30 +46,30 @@ discard block |
||
46 | 46 | public function testget_summary_text() |
47 | 47 | { |
48 | 48 | |
49 | - $campaignTracker = new CampaignTracker(); |
|
49 | + $campaignTracker = new CampaignTracker(); |
|
50 | 50 | |
51 | - //test without setting name |
|
52 | - $this->assertEquals(Null,$campaignTracker->get_summary_text()); |
|
51 | + //test without setting name |
|
52 | + $this->assertEquals(Null,$campaignTracker->get_summary_text()); |
|
53 | 53 | |
54 | - //test with name set |
|
55 | - $campaignTracker->tracker_name = "test"; |
|
56 | - $this->assertEquals('test',$campaignTracker->get_summary_text()); |
|
54 | + //test with name set |
|
55 | + $campaignTracker->tracker_name = "test"; |
|
56 | + $this->assertEquals('test',$campaignTracker->get_summary_text()); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | |
60 | 60 | |
61 | 61 | public function testfill_in_additional_detail_fields() |
62 | 62 | { |
63 | - $campaignTracker = new CampaignTracker(); |
|
63 | + $campaignTracker = new CampaignTracker(); |
|
64 | 64 | |
65 | - //test without is_optout set |
|
66 | - $campaignTracker->fill_in_additional_detail_fields(); |
|
67 | - $this->assertStringEndsWith("/index.php?entryPoint=campaign_trackerv2&track=", $campaignTracker->message_url); |
|
65 | + //test without is_optout set |
|
66 | + $campaignTracker->fill_in_additional_detail_fields(); |
|
67 | + $this->assertStringEndsWith("/index.php?entryPoint=campaign_trackerv2&track=", $campaignTracker->message_url); |
|
68 | 68 | |
69 | - //test with is_optout set |
|
70 | - $campaignTracker->is_optout = 1; |
|
71 | - $campaignTracker->fill_in_additional_detail_fields(); |
|
72 | - $this->assertStringEndsWith("/index.php?entryPoint=removeme&identifier={MESSAGE_ID}", $campaignTracker->message_url); |
|
69 | + //test with is_optout set |
|
70 | + $campaignTracker->is_optout = 1; |
|
71 | + $campaignTracker->fill_in_additional_detail_fields(); |
|
72 | + $this->assertStringEndsWith("/index.php?entryPoint=removeme&identifier={MESSAGE_ID}", $campaignTracker->message_url); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 |
@@ -3,184 +3,184 @@ |
||
3 | 3 | class SavedSearchTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testSavedSearch() { |
|
6 | + public function testSavedSearch() { |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $savedSearch = new SavedSearch(); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $savedSearch = new SavedSearch(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('SavedSearch',$savedSearch); |
|
12 | - $this->assertInstanceOf('SugarBean',$savedSearch); |
|
11 | + $this->assertInstanceOf('SavedSearch',$savedSearch); |
|
12 | + $this->assertInstanceOf('SugarBean',$savedSearch); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('saved_search', 'table_name', $savedSearch); |
|
15 | - $this->assertAttributeEquals('SavedSearch', 'module_dir', $savedSearch); |
|
16 | - $this->assertAttributeEquals('SavedSearch', 'object_name', $savedSearch); |
|
14 | + $this->assertAttributeEquals('saved_search', 'table_name', $savedSearch); |
|
15 | + $this->assertAttributeEquals('SavedSearch', 'module_dir', $savedSearch); |
|
16 | + $this->assertAttributeEquals('SavedSearch', 'object_name', $savedSearch); |
|
17 | 17 | |
18 | 18 | |
19 | - //test with parameters |
|
20 | - $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
19 | + //test with parameters |
|
20 | + $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
21 | 21 | |
22 | - $this->assertAttributeEquals(array('id','name'), 'columns', $savedSearch); |
|
23 | - $this->assertAttributeEquals('id', 'orderBy', $savedSearch); |
|
24 | - $this->assertAttributeEquals('ASC', 'sortOrder', $savedSearch); |
|
22 | + $this->assertAttributeEquals(array('id','name'), 'columns', $savedSearch); |
|
23 | + $this->assertAttributeEquals('id', 'orderBy', $savedSearch); |
|
24 | + $this->assertAttributeEquals('ASC', 'sortOrder', $savedSearch); |
|
25 | 25 | |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - public function testgetForm() { |
|
29 | + public function testgetForm() { |
|
30 | 30 | |
31 | - error_reporting(E_ERROR | E_PARSE); |
|
31 | + error_reporting(E_ERROR | E_PARSE); |
|
32 | 32 | |
33 | - $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
34 | - $result = $savedSearch->getForm("Leads"); |
|
33 | + $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
34 | + $result = $savedSearch->getForm("Leads"); |
|
35 | 35 | |
36 | - $this->assertGreaterThan(0,strlen($result)); |
|
36 | + $this->assertGreaterThan(0,strlen($result)); |
|
37 | 37 | |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function testgetSelect() { |
|
40 | + public function testgetSelect() { |
|
41 | 41 | |
42 | - $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
43 | - $result = $savedSearch->getSelect("Leads"); |
|
42 | + $savedSearch = new SavedSearch(array('id','name'),'id','ASC'); |
|
43 | + $result = $savedSearch->getSelect("Leads"); |
|
44 | 44 | |
45 | - $this->assertGreaterThan(0,strlen($result)); |
|
45 | + $this->assertGreaterThan(0,strlen($result)); |
|
46 | 46 | |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - public function testMain() { |
|
49 | + public function testMain() { |
|
50 | 50 | |
51 | - $savedSearch = new SavedSearch(); |
|
51 | + $savedSearch = new SavedSearch(); |
|
52 | 52 | |
53 | - $savedSearch->name = "test"; |
|
54 | - $savedSearch->search_module = "Leads"; |
|
55 | - $savedSearch->save(); |
|
53 | + $savedSearch->name = "test"; |
|
54 | + $savedSearch->search_module = "Leads"; |
|
55 | + $savedSearch->save(); |
|
56 | 56 | |
57 | - //test for record ID to verify that record is saved |
|
58 | - $this->assertTrue(isset($savedSearch->id)); |
|
59 | - $this->assertEquals(36, strlen($savedSearch->id)); |
|
57 | + //test for record ID to verify that record is saved |
|
58 | + $this->assertTrue(isset($savedSearch->id)); |
|
59 | + $this->assertEquals(36, strlen($savedSearch->id)); |
|
60 | 60 | |
61 | 61 | |
62 | - //test handleSave method |
|
63 | - $this->handleSaveAndRetrieveSavedSearch($savedSearch->id); |
|
62 | + //test handleSave method |
|
63 | + $this->handleSaveAndRetrieveSavedSearch($savedSearch->id); |
|
64 | 64 | |
65 | 65 | |
66 | - //test returnSavedSearch method |
|
67 | - $this->returnSavedSearch($savedSearch->id); |
|
66 | + //test returnSavedSearch method |
|
67 | + $this->returnSavedSearch($savedSearch->id); |
|
68 | 68 | |
69 | 69 | |
70 | - //test returnSavedSearchContents method |
|
71 | - $this->returnSavedSearchContents($savedSearch->id); |
|
70 | + //test returnSavedSearchContents method |
|
71 | + $this->returnSavedSearchContents($savedSearch->id); |
|
72 | 72 | |
73 | 73 | |
74 | - //test handleDelete method |
|
75 | - $this->handleDelete($savedSearch->id); |
|
74 | + //test handleDelete method |
|
75 | + $this->handleDelete($savedSearch->id); |
|
76 | 76 | |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - public function handleSaveAndRetrieveSavedSearch($id) { |
|
79 | + public function handleSaveAndRetrieveSavedSearch($id) { |
|
80 | 80 | |
81 | - $savedSearch = new SavedSearch(); |
|
82 | - $searchModuleBean = new Lead(); |
|
81 | + $savedSearch = new SavedSearch(); |
|
82 | + $searchModuleBean = new Lead(); |
|
83 | 83 | |
84 | - $_REQUEST['search_module'] = 'Leads'; |
|
85 | - $_REQUEST['description'] = 'test description'; |
|
86 | - $_REQUEST['test_content'] = 'test text'; |
|
84 | + $_REQUEST['search_module'] = 'Leads'; |
|
85 | + $_REQUEST['description'] = 'test description'; |
|
86 | + $_REQUEST['test_content'] = 'test text'; |
|
87 | 87 | |
88 | - $expected = array( "search_module"=> "Leads", "description"=>"test description", "test_content"=>"test text", "advanced"=>true); |
|
88 | + $expected = array( "search_module"=> "Leads", "description"=>"test description", "test_content"=>"test text", "advanced"=>true); |
|
89 | 89 | |
90 | - //execute the method and then retrieve back to verify contents attribute |
|
91 | - $savedSearch->handleSave('', false, false, $id, $searchModuleBean); |
|
92 | - $savedSearch->retrieveSavedSearch($id); |
|
93 | - $this->assertSame($expected, $savedSearch->contents); |
|
90 | + //execute the method and then retrieve back to verify contents attribute |
|
91 | + $savedSearch->handleSave('', false, false, $id, $searchModuleBean); |
|
92 | + $savedSearch->retrieveSavedSearch($id); |
|
93 | + $this->assertSame($expected, $savedSearch->contents); |
|
94 | 94 | |
95 | - } |
|
95 | + } |
|
96 | 96 | |
97 | - public function handleDelete($id) { |
|
97 | + public function handleDelete($id) { |
|
98 | 98 | |
99 | - $savedSearch = new SavedSearch(); |
|
99 | + $savedSearch = new SavedSearch(); |
|
100 | 100 | |
101 | - $savedSearch->handleDelete($id); |
|
101 | + $savedSearch->handleDelete($id); |
|
102 | 102 | |
103 | - $result = $savedSearch->retrieve($id); |
|
104 | - $this->assertEquals(null,$result); |
|
103 | + $result = $savedSearch->retrieve($id); |
|
104 | + $this->assertEquals(null,$result); |
|
105 | 105 | |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - public function returnSavedSearch($id) { |
|
109 | - |
|
110 | - $savedSearch = new SavedSearch(); |
|
111 | - |
|
112 | - //execute the method and test if it works and does not throws an exception. |
|
113 | - try { |
|
114 | - $savedSearch->returnSavedSearch($id); |
|
115 | - $this->assertTrue(true); |
|
116 | - } |
|
117 | - catch (Exception $e) { |
|
118 | - $this->fail(); |
|
119 | - } |
|
108 | + public function returnSavedSearch($id) { |
|
109 | + |
|
110 | + $savedSearch = new SavedSearch(); |
|
111 | + |
|
112 | + //execute the method and test if it works and does not throws an exception. |
|
113 | + try { |
|
114 | + $savedSearch->returnSavedSearch($id); |
|
115 | + $this->assertTrue(true); |
|
116 | + } |
|
117 | + catch (Exception $e) { |
|
118 | + $this->fail(); |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - } |
|
122 | + } |
|
123 | 123 | |
124 | - public function returnSavedSearchContents($id) { |
|
124 | + public function returnSavedSearchContents($id) { |
|
125 | 125 | |
126 | - $savedSearch = new SavedSearch(); |
|
126 | + $savedSearch = new SavedSearch(); |
|
127 | 127 | |
128 | - //execute the method and test if it works and does not throws an exception. |
|
129 | - try { |
|
130 | - $result = $savedSearch->returnSavedSearchContents($id); |
|
131 | - $this->assertTrue(true); |
|
132 | - } |
|
133 | - catch (Exception $e) { |
|
134 | - $this->fail(); |
|
135 | - } |
|
128 | + //execute the method and test if it works and does not throws an exception. |
|
129 | + try { |
|
130 | + $result = $savedSearch->returnSavedSearchContents($id); |
|
131 | + $this->assertTrue(true); |
|
132 | + } |
|
133 | + catch (Exception $e) { |
|
134 | + $this->fail(); |
|
135 | + } |
|
136 | 136 | |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | 139 | |
140 | - public function testhandleRedirect() { |
|
140 | + public function testhandleRedirect() { |
|
141 | 141 | |
142 | - $savedSearch = new SavedSearch(); |
|
142 | + $savedSearch = new SavedSearch(); |
|
143 | 143 | |
144 | - $search_query = "&orderBy=&sortOrder=&query=&searchFormTab=&showSSDIV="; |
|
144 | + $search_query = "&orderBy=&sortOrder=&query=&searchFormTab=&showSSDIV="; |
|
145 | 145 | |
146 | - //$savedSearch->handleRedirect("Leads", $search_query, 1, 'true'); |
|
147 | - $this->markTestIncomplete('method uses die'); |
|
146 | + //$savedSearch->handleRedirect("Leads", $search_query, 1, 'true'); |
|
147 | + $this->markTestIncomplete('method uses die'); |
|
148 | 148 | |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | - public function testfill_in_additional_list_fields() { |
|
151 | + public function testfill_in_additional_list_fields() { |
|
152 | 152 | |
153 | - $savedSearch = new SavedSearch(); |
|
153 | + $savedSearch = new SavedSearch(); |
|
154 | 154 | |
155 | - $savedSearch->assigned_user_id = 1; |
|
156 | - $savedSearch->contents = array('search_module'=>'Leads'); |
|
155 | + $savedSearch->assigned_user_id = 1; |
|
156 | + $savedSearch->contents = array('search_module'=>'Leads'); |
|
157 | 157 | |
158 | - $savedSearch->fill_in_additional_list_fields(); |
|
158 | + $savedSearch->fill_in_additional_list_fields(); |
|
159 | 159 | |
160 | - $this->assertEquals('Leads', $savedSearch->search_module); |
|
161 | - $this->assertEquals('Administrator', $savedSearch->assigned_user_name); |
|
160 | + $this->assertEquals('Leads', $savedSearch->search_module); |
|
161 | + $this->assertEquals('Administrator', $savedSearch->assigned_user_name); |
|
162 | 162 | |
163 | - } |
|
163 | + } |
|
164 | 164 | |
165 | 165 | |
166 | - public function testpopulateRequest(){ |
|
166 | + public function testpopulateRequest(){ |
|
167 | 167 | |
168 | - $savedSearch = new SavedSearch(); |
|
168 | + $savedSearch = new SavedSearch(); |
|
169 | 169 | |
170 | - $savedSearch->contents = array( "search_module"=> "Accounts", |
|
171 | - "description"=>"test text", |
|
172 | - "test_content"=>"some content", |
|
173 | - "advanced"=>true); |
|
170 | + $savedSearch->contents = array( "search_module"=> "Accounts", |
|
171 | + "description"=>"test text", |
|
172 | + "test_content"=>"some content", |
|
173 | + "advanced"=>true); |
|
174 | 174 | |
175 | - $savedSearch->populateRequest(); |
|
175 | + $savedSearch->populateRequest(); |
|
176 | 176 | |
177 | - //verify thhat Request parameters are set |
|
178 | - $this->assertEquals('Accounts', $_REQUEST['search_module']); |
|
179 | - $this->assertEquals('test text', $_REQUEST['description']); |
|
180 | - $this->assertEquals('some content', $_REQUEST['test_content']); |
|
177 | + //verify thhat Request parameters are set |
|
178 | + $this->assertEquals('Accounts', $_REQUEST['search_module']); |
|
179 | + $this->assertEquals('test text', $_REQUEST['description']); |
|
180 | + $this->assertEquals('some content', $_REQUEST['test_content']); |
|
181 | 181 | |
182 | 182 | |
183 | - } |
|
183 | + } |
|
184 | 184 | |
185 | 185 | } |
186 | 186 |
@@ -3,22 +3,22 @@ |
||
3 | 3 | class EmailTextTest extends PHPUnit_Framework_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - public function testEmailText() { |
|
6 | + public function testEmailText() { |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $emailText = new EmailText(); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $emailText = new EmailText(); |
|
10 | 10 | |
11 | - $this->assertInstanceOf('EmailText',$emailText); |
|
12 | - $this->assertInstanceOf('SugarBean',$emailText); |
|
11 | + $this->assertInstanceOf('EmailText',$emailText); |
|
12 | + $this->assertInstanceOf('SugarBean',$emailText); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('EmailText', 'module_dir', $emailText); |
|
15 | - $this->assertAttributeEquals('EmailText', 'module_name', $emailText); |
|
16 | - $this->assertAttributeEquals('EmailText', 'object_name', $emailText); |
|
17 | - $this->assertAttributeEquals('emails_text', 'table_name', $emailText); |
|
14 | + $this->assertAttributeEquals('EmailText', 'module_dir', $emailText); |
|
15 | + $this->assertAttributeEquals('EmailText', 'module_name', $emailText); |
|
16 | + $this->assertAttributeEquals('EmailText', 'object_name', $emailText); |
|
17 | + $this->assertAttributeEquals('emails_text', 'table_name', $emailText); |
|
18 | 18 | |
19 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $emailText); |
|
20 | - $this->assertAttributeEquals(true, 'disable_custom_fields', $emailText); |
|
19 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $emailText); |
|
20 | + $this->assertAttributeEquals(true, 'disable_custom_fields', $emailText); |
|
21 | 21 | |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -3,330 +3,330 @@ |
||
3 | 3 | class AOW_WorkFlowTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | 5 | |
6 | - public function testAOW_WorkFlow(){ |
|
6 | + public function testAOW_WorkFlow(){ |
|
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
10 | - $this->assertInstanceOf('AOW_WorkFlow',$aowWorkFlow); |
|
11 | - $this->assertInstanceOf('Basic',$aowWorkFlow); |
|
12 | - $this->assertInstanceOf('SugarBean',$aowWorkFlow); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
10 | + $this->assertInstanceOf('AOW_WorkFlow',$aowWorkFlow); |
|
11 | + $this->assertInstanceOf('Basic',$aowWorkFlow); |
|
12 | + $this->assertInstanceOf('SugarBean',$aowWorkFlow); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('AOW_WorkFlow', 'module_dir', $aowWorkFlow); |
|
15 | - $this->assertAttributeEquals('AOW_WorkFlow', 'object_name', $aowWorkFlow); |
|
16 | - $this->assertAttributeEquals('aow_workflow', 'table_name', $aowWorkFlow); |
|
17 | - $this->assertAttributeEquals(true, 'new_schema', $aowWorkFlow); |
|
18 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aowWorkFlow); |
|
19 | - $this->assertAttributeEquals(false, 'importable', $aowWorkFlow); |
|
14 | + $this->assertAttributeEquals('AOW_WorkFlow', 'module_dir', $aowWorkFlow); |
|
15 | + $this->assertAttributeEquals('AOW_WorkFlow', 'object_name', $aowWorkFlow); |
|
16 | + $this->assertAttributeEquals('aow_workflow', 'table_name', $aowWorkFlow); |
|
17 | + $this->assertAttributeEquals(true, 'new_schema', $aowWorkFlow); |
|
18 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aowWorkFlow); |
|
19 | + $this->assertAttributeEquals(false, 'importable', $aowWorkFlow); |
|
20 | 20 | |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - public function testbean_implements(){ |
|
23 | + public function testbean_implements(){ |
|
24 | 24 | |
25 | - error_reporting(E_ERROR | E_PARSE); |
|
25 | + error_reporting(E_ERROR | E_PARSE); |
|
26 | 26 | |
27 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
28 | - $this->assertEquals(false, $aowWorkFlow->bean_implements('')); //test with blank value |
|
29 | - $this->assertEquals(false, $aowWorkFlow->bean_implements('test')); //test with invalid value |
|
30 | - $this->assertEquals(true, $aowWorkFlow->bean_implements('ACL')); //test with valid value |
|
27 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
28 | + $this->assertEquals(false, $aowWorkFlow->bean_implements('')); //test with blank value |
|
29 | + $this->assertEquals(false, $aowWorkFlow->bean_implements('test')); //test with invalid value |
|
30 | + $this->assertEquals(true, $aowWorkFlow->bean_implements('ACL')); //test with valid value |
|
31 | 31 | |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | 34 | public function testsave(){ |
35 | 35 | |
36 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
36 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
37 | 37 | |
38 | - $aowWorkFlow->name = "test"; |
|
39 | - $aowWorkFlow->flow_module = 'test'; |
|
38 | + $aowWorkFlow->name = "test"; |
|
39 | + $aowWorkFlow->flow_module = 'test'; |
|
40 | 40 | |
41 | - $aowWorkFlow->save(); |
|
41 | + $aowWorkFlow->save(); |
|
42 | 42 | |
43 | - //test for record ID to verify that record is saved |
|
44 | - $this->assertTrue(isset($aowWorkFlow->id)); |
|
45 | - $this->assertEquals(36, strlen($aowWorkFlow->id)); |
|
43 | + //test for record ID to verify that record is saved |
|
44 | + $this->assertTrue(isset($aowWorkFlow->id)); |
|
45 | + $this->assertEquals(36, strlen($aowWorkFlow->id)); |
|
46 | 46 | |
47 | 47 | |
48 | - //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
49 | - $aowWorkFlow->mark_deleted($aowWorkFlow->id); |
|
50 | - $result = $aowWorkFlow->retrieve($aowWorkFlow->id); |
|
51 | - $this->assertEquals(null,$result); |
|
48 | + //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
49 | + $aowWorkFlow->mark_deleted($aowWorkFlow->id); |
|
50 | + $result = $aowWorkFlow->retrieve($aowWorkFlow->id); |
|
51 | + $this->assertEquals(null,$result); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function testload_flow_beans(){ |
56 | 56 | |
57 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
57 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
58 | 58 | |
59 | - //execute the method and test if it works and does not throws an exception. |
|
60 | - try { |
|
61 | - $aowWorkFlow->load_flow_beans(); |
|
62 | - $this->assertTrue(true); |
|
63 | - } |
|
64 | - catch (Exception $e) { |
|
65 | - $this->fail(); |
|
66 | - } |
|
59 | + //execute the method and test if it works and does not throws an exception. |
|
60 | + try { |
|
61 | + $aowWorkFlow->load_flow_beans(); |
|
62 | + $this->assertTrue(true); |
|
63 | + } |
|
64 | + catch (Exception $e) { |
|
65 | + $this->fail(); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | - public function testrun_flows(){ |
|
71 | + public function testrun_flows(){ |
|
72 | 72 | |
73 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
73 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
74 | 74 | |
75 | - $result = $aowWorkFlow->run_flows(); |
|
76 | - $this->assertTrue($result); |
|
75 | + $result = $aowWorkFlow->run_flows(); |
|
76 | + $this->assertTrue($result); |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | public function testrun_flow(){ |
82 | 82 | |
83 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
83 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
84 | 84 | |
85 | - //execute the method and test if it works and does not throws an exception. |
|
86 | - try { |
|
87 | - $aowWorkFlow->run_flow(); |
|
88 | - $this->assertTrue(true); |
|
89 | - } |
|
90 | - catch (Exception $e) { |
|
91 | - $this->fail(); |
|
92 | - } |
|
85 | + //execute the method and test if it works and does not throws an exception. |
|
86 | + try { |
|
87 | + $aowWorkFlow->run_flow(); |
|
88 | + $this->assertTrue(true); |
|
89 | + } |
|
90 | + catch (Exception $e) { |
|
91 | + $this->fail(); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | 96 | |
97 | 97 | public function testrun_bean_flows(){ |
98 | 98 | |
99 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
99 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
100 | 100 | |
101 | - //test with different modules. it always returns true |
|
101 | + //test with different modules. it always returns true |
|
102 | 102 | |
103 | - $result = $aowWorkFlow->run_bean_flows(new AOS_Quotes()); |
|
104 | - $this->assertTrue($result); |
|
103 | + $result = $aowWorkFlow->run_bean_flows(new AOS_Quotes()); |
|
104 | + $this->assertTrue($result); |
|
105 | 105 | |
106 | - $result = $aowWorkFlow->run_bean_flows(new Call()); |
|
107 | - $this->assertTrue($result); |
|
106 | + $result = $aowWorkFlow->run_bean_flows(new Call()); |
|
107 | + $this->assertTrue($result); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | 112 | public function testget_flow_beans(){ |
113 | 113 | |
114 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
114 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
115 | 115 | |
116 | - //test for AOS_Quotes. it will return null as no test data is available |
|
117 | - $aowWorkFlow->flow_module = "AOS_Quotes"; |
|
118 | - $result = $aowWorkFlow->get_flow_beans(); |
|
119 | - $this->assertEquals(null,$result); |
|
116 | + //test for AOS_Quotes. it will return null as no test data is available |
|
117 | + $aowWorkFlow->flow_module = "AOS_Quotes"; |
|
118 | + $result = $aowWorkFlow->get_flow_beans(); |
|
119 | + $this->assertEquals(null,$result); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | public function testbuild_flow_query_join(){ |
123 | 123 | |
124 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
125 | - $query = Array(); |
|
124 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
125 | + $query = Array(); |
|
126 | 126 | |
127 | 127 | |
128 | - //test without type param |
|
129 | - $result = $aowWorkFlow->build_flow_query_join('aos_products_quotes', new AOS_Quotes(), '', Array()); |
|
130 | - $this->assertSame(array(), $result); |
|
128 | + //test without type param |
|
129 | + $result = $aowWorkFlow->build_flow_query_join('aos_products_quotes', new AOS_Quotes(), '', Array()); |
|
130 | + $this->assertSame(array(), $result); |
|
131 | 131 | |
132 | 132 | |
133 | - //test with type custom |
|
134 | - $expected = Array('join' => array('c' => 'LEFT JOIN calls_cstm c ON calls.id = c.id_c ' )); |
|
135 | - $result = $aowWorkFlow->build_flow_query_join('c', new Call(), 'custom', Array()); |
|
136 | - $this->assertSame($expected, $result); |
|
133 | + //test with type custom |
|
134 | + $expected = Array('join' => array('c' => 'LEFT JOIN calls_cstm c ON calls.id = c.id_c ' )); |
|
135 | + $result = $aowWorkFlow->build_flow_query_join('c', new Call(), 'custom', Array()); |
|
136 | + $this->assertSame($expected, $result); |
|
137 | 137 | |
138 | 138 | |
139 | - //test with type relationship |
|
140 | - $expected = Array ( |
|
141 | - 'join' =>array ("aos_products_quotes" => "LEFT JOIN aos_products_quotes aos_products_quotes ON aos_quotes.id=aos_products_quotes.parent_id AND aos_products_quotes.deleted=0\n\n"), |
|
142 | - 'select' =>array ("aos_products_quotes.id AS 'aos_products_quotes_id'"), |
|
143 | - ); |
|
144 | - $result = $aowWorkFlow->build_flow_query_join('aos_products_quotes', new AOS_Quotes(), 'relationship', Array()); |
|
145 | - $this->assertSame($expected, $result); |
|
139 | + //test with type relationship |
|
140 | + $expected = Array ( |
|
141 | + 'join' =>array ("aos_products_quotes" => "LEFT JOIN aos_products_quotes aos_products_quotes ON aos_quotes.id=aos_products_quotes.parent_id AND aos_products_quotes.deleted=0\n\n"), |
|
142 | + 'select' =>array ("aos_products_quotes.id AS 'aos_products_quotes_id'"), |
|
143 | + ); |
|
144 | + $result = $aowWorkFlow->build_flow_query_join('aos_products_quotes', new AOS_Quotes(), 'relationship', Array()); |
|
145 | + $this->assertSame($expected, $result); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function testbuild_flow_query_where(){ |
150 | 150 | |
151 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
151 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
152 | 152 | |
153 | - //test without presetting required object attributes |
|
154 | - $expected = Array(); |
|
155 | - $query = $aowWorkFlow->build_flow_query_where(); |
|
156 | - $this->assertSame($expected,$query); |
|
153 | + //test without presetting required object attributes |
|
154 | + $expected = Array(); |
|
155 | + $query = $aowWorkFlow->build_flow_query_where(); |
|
156 | + $this->assertSame($expected,$query); |
|
157 | 157 | |
158 | 158 | |
159 | 159 | |
160 | - //test with module required attributes set |
|
161 | - $aowWorkFlow->id = '1'; |
|
162 | - $aowWorkFlow->flow_module = "Calls"; |
|
163 | - $expected = array ( |
|
164 | - 'where' => array ('NOT EXISTS (SELECT * FROM aow_processed WHERE aow_processed.aow_workflow_id=\'1\' AND aow_processed.parent_id=calls.id AND aow_processed.status = \'Complete\' AND aow_processed.deleted = 0)', |
|
165 | - 'calls.deleted = 0 ' ) |
|
166 | - ); |
|
167 | - $query = $aowWorkFlow->build_flow_query_where(); |
|
168 | - $this->assertSame($expected,$query); |
|
160 | + //test with module required attributes set |
|
161 | + $aowWorkFlow->id = '1'; |
|
162 | + $aowWorkFlow->flow_module = "Calls"; |
|
163 | + $expected = array ( |
|
164 | + 'where' => array ('NOT EXISTS (SELECT * FROM aow_processed WHERE aow_processed.aow_workflow_id=\'1\' AND aow_processed.parent_id=calls.id AND aow_processed.status = \'Complete\' AND aow_processed.deleted = 0)', |
|
165 | + 'calls.deleted = 0 ' ) |
|
166 | + ); |
|
167 | + $query = $aowWorkFlow->build_flow_query_where(); |
|
168 | + $this->assertSame($expected,$query); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | |
172 | - //test with flow_run_on and multiple_runs attributes set |
|
173 | - $expected = array ( |
|
174 | - 'where' => array ('calls.date_entered > \'\'','calls.deleted = 0 '), |
|
175 | - ); |
|
176 | - $aowWorkFlow->flow_run_on = 'New_Records'; |
|
177 | - $aowWorkFlow->multiple_runs = 1; |
|
178 | - $query = $aowWorkFlow->build_flow_query_where(); |
|
179 | - $this->assertSame($expected,$query); |
|
172 | + //test with flow_run_on and multiple_runs attributes set |
|
173 | + $expected = array ( |
|
174 | + 'where' => array ('calls.date_entered > \'\'','calls.deleted = 0 '), |
|
175 | + ); |
|
176 | + $aowWorkFlow->flow_run_on = 'New_Records'; |
|
177 | + $aowWorkFlow->multiple_runs = 1; |
|
178 | + $query = $aowWorkFlow->build_flow_query_where(); |
|
179 | + $this->assertSame($expected,$query); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | 183 | public function testbuild_query_where(){ |
184 | 184 | |
185 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
185 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
186 | 186 | |
187 | - //populate required values |
|
188 | - $call = new Call(); |
|
189 | - $aowCondition = new AOW_Condition(); |
|
190 | - $aowCondition->name = "test"; |
|
191 | - $aowCondition->module_path = base64_encode(serialize(array(''))); |
|
192 | - $aowCondition->field = "name"; |
|
193 | - $aowCondition->value = "testval"; |
|
187 | + //populate required values |
|
188 | + $call = new Call(); |
|
189 | + $aowCondition = new AOW_Condition(); |
|
190 | + $aowCondition->name = "test"; |
|
191 | + $aowCondition->module_path = base64_encode(serialize(array(''))); |
|
192 | + $aowCondition->field = "name"; |
|
193 | + $aowCondition->value = "testval"; |
|
194 | 194 | |
195 | 195 | |
196 | 196 | |
197 | - //test with contains operator |
|
198 | - $aowCondition->operator = "Contains"; |
|
199 | - $aowCondition->value_type = "Value"; |
|
200 | - $expected = array( |
|
201 | - "where"=> array(".name LIKE CONCAT('%', 'testval' ,'%')") |
|
202 | - ); |
|
203 | - $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
204 | - $this->assertEquals($expected, $query); |
|
197 | + //test with contains operator |
|
198 | + $aowCondition->operator = "Contains"; |
|
199 | + $aowCondition->value_type = "Value"; |
|
200 | + $expected = array( |
|
201 | + "where"=> array(".name LIKE CONCAT('%', 'testval' ,'%')") |
|
202 | + ); |
|
203 | + $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
204 | + $this->assertEquals($expected, $query); |
|
205 | 205 | |
206 | 206 | |
207 | 207 | |
208 | - //test for starts with operator |
|
209 | - $aowCondition->operator = "Starts_With"; |
|
210 | - $aowCondition->value_type = "Value"; |
|
208 | + //test for starts with operator |
|
209 | + $aowCondition->operator = "Starts_With"; |
|
210 | + $aowCondition->value_type = "Value"; |
|
211 | 211 | |
212 | - $expected = array( |
|
213 | - "where"=> array(".name LIKE CONCAT('testval' ,'%')") |
|
214 | - ); |
|
215 | - $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
216 | - $this->assertEquals($expected, $query); |
|
212 | + $expected = array( |
|
213 | + "where"=> array(".name LIKE CONCAT('testval' ,'%')") |
|
214 | + ); |
|
215 | + $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
216 | + $this->assertEquals($expected, $query); |
|
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - //test for Equal_To operator |
|
221 | - $aowCondition->operator = "Equal_To"; |
|
222 | - $aowCondition->value_type = "Value"; |
|
220 | + //test for Equal_To operator |
|
221 | + $aowCondition->operator = "Equal_To"; |
|
222 | + $aowCondition->value_type = "Value"; |
|
223 | 223 | |
224 | - $expected = array( |
|
225 | - "where"=> array(".name = 'testval'") |
|
226 | - ); |
|
227 | - $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
228 | - $this->assertEquals($expected, $query); |
|
224 | + $expected = array( |
|
225 | + "where"=> array(".name = 'testval'") |
|
226 | + ); |
|
227 | + $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
228 | + $this->assertEquals($expected, $query); |
|
229 | 229 | |
230 | 230 | |
231 | 231 | |
232 | - //test with value type Date |
|
233 | - $aowCondition->operator = "Equal_To"; |
|
234 | - $aowCondition->value_type = "Date"; |
|
232 | + //test with value type Date |
|
233 | + $aowCondition->operator = "Equal_To"; |
|
234 | + $aowCondition->value_type = "Date"; |
|
235 | 235 | |
236 | - $expected = array( |
|
237 | - "where"=> array('.name = DATE_ADD(calls., INTERVAL )') |
|
238 | - ); |
|
236 | + $expected = array( |
|
237 | + "where"=> array('.name = DATE_ADD(calls., INTERVAL )') |
|
238 | + ); |
|
239 | 239 | |
240 | - $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
241 | - $this->assertEquals($expected, $query); |
|
240 | + $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
241 | + $this->assertEquals($expected, $query); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | |
245 | - //test with value type Field |
|
246 | - $aowCondition->operator = "Equal_To"; |
|
247 | - $aowCondition->value_type = "Field"; |
|
245 | + //test with value type Field |
|
246 | + $aowCondition->operator = "Equal_To"; |
|
247 | + $aowCondition->value_type = "Field"; |
|
248 | 248 | |
249 | - $expected = array( |
|
250 | - "where"=> array('.name = calls.testval') |
|
251 | - ); |
|
249 | + $expected = array( |
|
250 | + "where"=> array('.name = calls.testval') |
|
251 | + ); |
|
252 | 252 | |
253 | - $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
254 | - $this->assertEquals($expected, $query); |
|
253 | + $query = $aowWorkFlow->build_query_where($aowCondition, $call); |
|
254 | + $this->assertEquals($expected, $query); |
|
255 | 255 | |
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | 259 | public function testcheck_valid_bean(){ |
260 | 260 | |
261 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
262 | - $aowWorkFlow->flow_run_on = "New_Records"; |
|
261 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
262 | + $aowWorkFlow->flow_run_on = "New_Records"; |
|
263 | 263 | |
264 | - $aosQuotes = new AOS_Quotes(); |
|
264 | + $aosQuotes = new AOS_Quotes(); |
|
265 | 265 | |
266 | - $result = $aowWorkFlow->check_valid_bean($aosQuotes); |
|
267 | - $this->assertTrue($result); |
|
266 | + $result = $aowWorkFlow->check_valid_bean($aosQuotes); |
|
267 | + $this->assertTrue($result); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | public function testcompare_condition(){ |
272 | 272 | |
273 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
273 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
274 | 274 | |
275 | - //execute the method and verify that it returns valid values for all operators |
|
275 | + //execute the method and verify that it returns valid values for all operators |
|
276 | 276 | |
277 | - $this->assertTrue($aowWorkFlow->compare_condition(1,1)); |
|
278 | - $this->assertTrue($aowWorkFlow->compare_condition(1,2,'Not_Equal_To' )); |
|
279 | - $this->assertTrue($aowWorkFlow->compare_condition(2,1,'Greater_Than' )); |
|
280 | - $this->assertTrue($aowWorkFlow->compare_condition(1,2,'Less_Than' )); |
|
281 | - $this->assertTrue($aowWorkFlow->compare_condition(5,4,'Greater_Than_or_Equal_To' )); |
|
282 | - $this->assertTrue($aowWorkFlow->compare_condition(2,3,'Less_Than_or_Equal_To' )); |
|
283 | - $this->assertNotFalse($aowWorkFlow->compare_condition('test1','test','Contains' )); |
|
284 | - $this->assertNotFalse($aowWorkFlow->compare_condition('test1','test','Starts_With' )); |
|
285 | - $this->assertNotFalse($aowWorkFlow->compare_condition('test1','1','Ends_With' )); |
|
286 | - $this->assertTrue($aowWorkFlow->compare_condition('','','is_null' )); |
|
287 | - $this->assertTrue($aowWorkFlow->compare_condition('test2',array('test1','test2'),'One_of' )); |
|
288 | - $this->assertTrue($aowWorkFlow->compare_condition('test', array('test1','test2'),'Not_One_of' )); |
|
277 | + $this->assertTrue($aowWorkFlow->compare_condition(1,1)); |
|
278 | + $this->assertTrue($aowWorkFlow->compare_condition(1,2,'Not_Equal_To' )); |
|
279 | + $this->assertTrue($aowWorkFlow->compare_condition(2,1,'Greater_Than' )); |
|
280 | + $this->assertTrue($aowWorkFlow->compare_condition(1,2,'Less_Than' )); |
|
281 | + $this->assertTrue($aowWorkFlow->compare_condition(5,4,'Greater_Than_or_Equal_To' )); |
|
282 | + $this->assertTrue($aowWorkFlow->compare_condition(2,3,'Less_Than_or_Equal_To' )); |
|
283 | + $this->assertNotFalse($aowWorkFlow->compare_condition('test1','test','Contains' )); |
|
284 | + $this->assertNotFalse($aowWorkFlow->compare_condition('test1','test','Starts_With' )); |
|
285 | + $this->assertNotFalse($aowWorkFlow->compare_condition('test1','1','Ends_With' )); |
|
286 | + $this->assertTrue($aowWorkFlow->compare_condition('','','is_null' )); |
|
287 | + $this->assertTrue($aowWorkFlow->compare_condition('test2',array('test1','test2'),'One_of' )); |
|
288 | + $this->assertTrue($aowWorkFlow->compare_condition('test', array('test1','test2'),'Not_One_of' )); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
292 | 292 | public function testcheck_in_group(){ |
293 | 293 | |
294 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
294 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
295 | 295 | |
296 | - //test with two different modules |
|
297 | - $this->assertFalse($aowWorkFlow->check_in_group(1, "Users", 1)); |
|
298 | - $this->assertFalse($aowWorkFlow->check_in_group(1, "Calls", 1)); |
|
296 | + //test with two different modules |
|
297 | + $this->assertFalse($aowWorkFlow->check_in_group(1, "Users", 1)); |
|
298 | + $this->assertFalse($aowWorkFlow->check_in_group(1, "Calls", 1)); |
|
299 | 299 | |
300 | 300 | } |
301 | 301 | |
302 | 302 | |
303 | 303 | public function testrun_actions(){ |
304 | 304 | |
305 | - $aowWorkFlow = new AOW_WorkFlow(); |
|
305 | + $aowWorkFlow = new AOW_WorkFlow(); |
|
306 | 306 | |
307 | - //prepare the required objects and variables |
|
308 | - $aowWorkFlow->id = 1; |
|
307 | + //prepare the required objects and variables |
|
308 | + $aowWorkFlow->id = 1; |
|
309 | 309 | |
310 | - $call = new Call(); |
|
311 | - $call->id = 1; |
|
310 | + $call = new Call(); |
|
311 | + $call->id = 1; |
|
312 | 312 | |
313 | - //execute the method and verify if it creates records in processed table |
|
314 | - $result = $aowWorkFlow->run_actions($call); |
|
313 | + //execute the method and verify if it creates records in processed table |
|
314 | + $result = $aowWorkFlow->run_actions($call); |
|
315 | 315 | |
316 | 316 | |
317 | - //test for a entry in AOW_Processed table. |
|
318 | - $processed = new AOW_Processed(); |
|
319 | - $processed->retrieve_by_string_fields(array('aow_workflow_id' => 1,'parent_id' => 1)); |
|
317 | + //test for a entry in AOW_Processed table. |
|
318 | + $processed = new AOW_Processed(); |
|
319 | + $processed->retrieve_by_string_fields(array('aow_workflow_id' => 1,'parent_id' => 1)); |
|
320 | 320 | |
321 | - //test for record ID to verify that record is saved |
|
322 | - $this->assertTrue(isset($processed->id)); |
|
323 | - $this->assertEquals(36, strlen($processed->id)); |
|
321 | + //test for record ID to verify that record is saved |
|
322 | + $this->assertTrue(isset($processed->id)); |
|
323 | + $this->assertEquals(36, strlen($processed->id)); |
|
324 | 324 | |
325 | 325 | |
326 | - //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
327 | - $processed->mark_deleted($processed->id); |
|
328 | - $result = $processed->retrieve($processed->id); |
|
329 | - $this->assertEquals(null,$result); |
|
326 | + //mark the record as deleted and verify that this record cannot be retrieved anymore. |
|
327 | + $processed->mark_deleted($processed->id); |
|
328 | + $result = $processed->retrieve($processed->id); |
|
329 | + $this->assertEquals(null,$result); |
|
330 | 330 | |
331 | 331 | } |
332 | 332 |
@@ -2,23 +2,23 @@ |
||
2 | 2 | |
3 | 3 | class AOS_PDF_TemplatesTest extends PHPUnit_Framework_TestCase { |
4 | 4 | |
5 | - public function testAOS_PDF_Templates(){ |
|
5 | + public function testAOS_PDF_Templates(){ |
|
6 | 6 | |
7 | 7 | |
8 | - //execute the contructor and check for the Object type and attributes |
|
9 | - $aosPdfTemplates = new AOS_PDF_Templates(); |
|
10 | - $this->assertInstanceOf('AOS_PDF_Templates',$aosPdfTemplates); |
|
11 | - $this->assertInstanceOf('Basic',$aosPdfTemplates); |
|
12 | - $this->assertInstanceOf('SugarBean',$aosPdfTemplates); |
|
8 | + //execute the contructor and check for the Object type and attributes |
|
9 | + $aosPdfTemplates = new AOS_PDF_Templates(); |
|
10 | + $this->assertInstanceOf('AOS_PDF_Templates',$aosPdfTemplates); |
|
11 | + $this->assertInstanceOf('Basic',$aosPdfTemplates); |
|
12 | + $this->assertInstanceOf('SugarBean',$aosPdfTemplates); |
|
13 | 13 | |
14 | - $this->assertAttributeEquals('AOS_PDF_Templates', 'module_dir', $aosPdfTemplates); |
|
15 | - $this->assertAttributeEquals('AOS_PDF_Templates', 'object_name', $aosPdfTemplates); |
|
16 | - $this->assertAttributeEquals('aos_pdf_templates', 'table_name', $aosPdfTemplates); |
|
17 | - $this->assertAttributeEquals(true, 'new_schema', $aosPdfTemplates); |
|
18 | - $this->assertAttributeEquals(true, 'disable_row_level_security', $aosPdfTemplates); |
|
19 | - $this->assertAttributeEquals(true, 'importable', $aosPdfTemplates); |
|
14 | + $this->assertAttributeEquals('AOS_PDF_Templates', 'module_dir', $aosPdfTemplates); |
|
15 | + $this->assertAttributeEquals('AOS_PDF_Templates', 'object_name', $aosPdfTemplates); |
|
16 | + $this->assertAttributeEquals('aos_pdf_templates', 'table_name', $aosPdfTemplates); |
|
17 | + $this->assertAttributeEquals(true, 'new_schema', $aosPdfTemplates); |
|
18 | + $this->assertAttributeEquals(true, 'disable_row_level_security', $aosPdfTemplates); |
|
19 | + $this->assertAttributeEquals(true, 'importable', $aosPdfTemplates); |
|
20 | 20 | |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | 23 | } |
24 | 24 | ?> |
25 | 25 | \ No newline at end of file |