@@ -4,166 +4,166 @@ |
||
4 | 4 | class SugarControllerTest extends PHPUnit_Framework_TestCase |
5 | 5 | { |
6 | 6 | |
7 | - public function testsetup(){ |
|
7 | + public function testsetup(){ |
|
8 | 8 | |
9 | 9 | |
10 | - $SugarController = new SugarController(); |
|
11 | - $default_module = $SugarController->module; |
|
10 | + $SugarController = new SugarController(); |
|
11 | + $default_module = $SugarController->module; |
|
12 | 12 | |
13 | - //first test with empty parameter and check for default values being used |
|
14 | - $SugarController->setup(''); |
|
15 | - $this->assertAttributeEquals($default_module,'module', $SugarController); |
|
16 | - $this->assertAttributeEquals(null,'target_module', $SugarController); |
|
17 | - |
|
18 | - //secondly test with module name and check for correct assignment. |
|
19 | - $SugarController->setup('Users'); |
|
20 | - $this->assertAttributeEquals('Users','module', $SugarController); |
|
21 | - $this->assertAttributeEquals(null,'target_module', $SugarController); |
|
13 | + //first test with empty parameter and check for default values being used |
|
14 | + $SugarController->setup(''); |
|
15 | + $this->assertAttributeEquals($default_module,'module', $SugarController); |
|
16 | + $this->assertAttributeEquals(null,'target_module', $SugarController); |
|
17 | + |
|
18 | + //secondly test with module name and check for correct assignment. |
|
19 | + $SugarController->setup('Users'); |
|
20 | + $this->assertAttributeEquals('Users','module', $SugarController); |
|
21 | + $this->assertAttributeEquals(null,'target_module', $SugarController); |
|
22 | 22 | |
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - public function testsetModule(){ |
|
27 | - $SugarController = new SugarController(); |
|
26 | + public function testsetModule(){ |
|
27 | + $SugarController = new SugarController(); |
|
28 | 28 | |
29 | - //first test with empty parameter |
|
30 | - $SugarController->setModule(''); |
|
31 | - $this->assertAttributeEquals('','module', $SugarController); |
|
29 | + //first test with empty parameter |
|
30 | + $SugarController->setModule(''); |
|
31 | + $this->assertAttributeEquals('','module', $SugarController); |
|
32 | 32 | |
33 | - //secondly test with module name and check for correct assignment. |
|
34 | - $SugarController->setModule('Users'); |
|
35 | - $this->assertAttributeEquals('Users','module', $SugarController); |
|
36 | - } |
|
33 | + //secondly test with module name and check for correct assignment. |
|
34 | + $SugarController->setModule('Users'); |
|
35 | + $this->assertAttributeEquals('Users','module', $SugarController); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - public function testloadBean() |
|
40 | - { |
|
41 | - $SugarController = new SugarController(); |
|
39 | + public function testloadBean() |
|
40 | + { |
|
41 | + $SugarController = new SugarController(); |
|
42 | 42 | |
43 | - //first test with empty parameter and check for null. Default is Home but Home has no bean |
|
44 | - $SugarController->setModule(''); |
|
45 | - $SugarController->loadBean(); |
|
46 | - $this->assertEquals(null,$SugarController->bean ); |
|
43 | + //first test with empty parameter and check for null. Default is Home but Home has no bean |
|
44 | + $SugarController->setModule(''); |
|
45 | + $SugarController->loadBean(); |
|
46 | + $this->assertEquals(null,$SugarController->bean ); |
|
47 | 47 | |
48 | - //secondly test with module name and check for correct bean class loaded. |
|
49 | - $SugarController->setModule('Users'); |
|
50 | - $SugarController->loadBean(); |
|
51 | - $this->assertInstanceOf('User',$SugarController->bean); |
|
48 | + //secondly test with module name and check for correct bean class loaded. |
|
49 | + $SugarController->setModule('Users'); |
|
50 | + $SugarController->loadBean(); |
|
51 | + $this->assertInstanceOf('User',$SugarController->bean); |
|
52 | 52 | |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - public function testexecute() |
|
56 | + public function testexecute() |
|
57 | 57 | { |
58 | - $SugarController = new SugarController(); |
|
58 | + $SugarController = new SugarController(); |
|
59 | 59 | |
60 | - //execute the method and check if it works and doesn't throws an exception |
|
61 | - try { |
|
62 | - $SugarController->execute(); |
|
63 | - } catch (Exception $e) { |
|
64 | - $this->fail(); |
|
65 | - } |
|
60 | + //execute the method and check if it works and doesn't throws an exception |
|
61 | + try { |
|
62 | + $SugarController->execute(); |
|
63 | + } catch (Exception $e) { |
|
64 | + $this->fail(); |
|
65 | + } |
|
66 | 66 | |
67 | - $this->assertTrue(TRUE); |
|
67 | + $this->assertTrue(TRUE); |
|
68 | 68 | |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - public function testprocess(){ |
|
72 | + public function testprocess(){ |
|
73 | 73 | |
74 | - $SugarController = new SugarController(); |
|
74 | + $SugarController = new SugarController(); |
|
75 | 75 | |
76 | - //execute the method and check if it works and doesn't throws an exception |
|
77 | - try { |
|
78 | - $SugarController->process(); |
|
79 | - } catch (Exception $e) { |
|
80 | - $this->fail(); |
|
81 | - } |
|
76 | + //execute the method and check if it works and doesn't throws an exception |
|
77 | + try { |
|
78 | + $SugarController->process(); |
|
79 | + } catch (Exception $e) { |
|
80 | + $this->fail(); |
|
81 | + } |
|
82 | 82 | |
83 | - $this->assertTrue(TRUE); |
|
83 | + $this->assertTrue(TRUE); |
|
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - public function testpre_save(){ |
|
88 | + public function testpre_save(){ |
|
89 | 89 | |
90 | - $SugarController = new SugarController(); |
|
91 | - $SugarController->setModule('Users'); |
|
92 | - $SugarController->loadBean(); |
|
90 | + $SugarController = new SugarController(); |
|
91 | + $SugarController->setModule('Users'); |
|
92 | + $SugarController->loadBean(); |
|
93 | 93 | |
94 | - //execute the method and check if it either works or throws an mysql exception. |
|
95 | - //Fail if it throws any other exception. |
|
96 | - try { |
|
97 | - $SugarController->pre_save(); |
|
98 | - } catch (Exception $e) { |
|
99 | - $this->assertStringStartsWith('mysqli_query()', $e->getMessage()); |
|
100 | - } |
|
94 | + //execute the method and check if it either works or throws an mysql exception. |
|
95 | + //Fail if it throws any other exception. |
|
96 | + try { |
|
97 | + $SugarController->pre_save(); |
|
98 | + } catch (Exception $e) { |
|
99 | + $this->assertStringStartsWith('mysqli_query()', $e->getMessage()); |
|
100 | + } |
|
101 | 101 | |
102 | - $this->assertTrue(TRUE); |
|
102 | + $this->assertTrue(TRUE); |
|
103 | 103 | |
104 | - } |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - public function testaction_save(){ |
|
107 | + public function testaction_save(){ |
|
108 | 108 | |
109 | - $SugarController = new SugarController(); |
|
110 | - $SugarController->setModule('Users'); |
|
111 | - $SugarController->loadBean(); |
|
109 | + $SugarController = new SugarController(); |
|
110 | + $SugarController->setModule('Users'); |
|
111 | + $SugarController->loadBean(); |
|
112 | 112 | |
113 | - //execute the method and check if it either works or throws an mysql exception. |
|
114 | - //Fail if it throws any other exception. |
|
115 | - try { |
|
116 | - $SugarController->action_save(); |
|
117 | - } catch (Exception $e) { |
|
118 | - $this->assertStringStartsWith('mysqli_query()', $e->getMessage()); |
|
119 | - } |
|
113 | + //execute the method and check if it either works or throws an mysql exception. |
|
114 | + //Fail if it throws any other exception. |
|
115 | + try { |
|
116 | + $SugarController->action_save(); |
|
117 | + } catch (Exception $e) { |
|
118 | + $this->assertStringStartsWith('mysqli_query()', $e->getMessage()); |
|
119 | + } |
|
120 | 120 | |
121 | - $this->assertTrue(TRUE); |
|
121 | + $this->assertTrue(TRUE); |
|
122 | 122 | |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | |
126 | 126 | public function testaction_spot() |
127 | 127 | { |
128 | - $SugarController = new SugarController(); |
|
128 | + $SugarController = new SugarController(); |
|
129 | 129 | |
130 | - //first check with default value of attribute |
|
131 | - $this->assertAttributeEquals('classic','view', $SugarController); |
|
130 | + //first check with default value of attribute |
|
131 | + $this->assertAttributeEquals('classic','view', $SugarController); |
|
132 | 132 | |
133 | - //secondly check for attribute value change on method execution. |
|
134 | - $SugarController->action_spot(); |
|
135 | - $this->assertAttributeEquals('spot','view', $SugarController); |
|
133 | + //secondly check for attribute value change on method execution. |
|
134 | + $SugarController->action_spot(); |
|
135 | + $this->assertAttributeEquals('spot','view', $SugarController); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
139 | - public function testgetActionFilename() { |
|
139 | + public function testgetActionFilename() { |
|
140 | 140 | |
141 | - //first check with a invalid value |
|
142 | - $action = SugarController::getActionFilename(''); |
|
143 | - $this->assertEquals('',$action ); |
|
141 | + //first check with a invalid value |
|
142 | + $action = SugarController::getActionFilename(''); |
|
143 | + $this->assertEquals('',$action ); |
|
144 | 144 | |
145 | - //secondly check with a valid value |
|
146 | - $action = SugarController::getActionFilename('editview'); |
|
147 | - $this->assertEquals('EditView',$action ); |
|
145 | + //secondly check with a valid value |
|
146 | + $action = SugarController::getActionFilename('editview'); |
|
147 | + $this->assertEquals('EditView',$action ); |
|
148 | 148 | |
149 | - } |
|
149 | + } |
|
150 | 150 | |
151 | 151 | |
152 | 152 | public function testcheckEntryPointRequiresAuth() |
153 | 153 | { |
154 | - $SugarController = new SugarController(); |
|
154 | + $SugarController = new SugarController(); |
|
155 | 155 | |
156 | - //check with a invalid value |
|
157 | - $result = $SugarController->checkEntryPointRequiresAuth(''); |
|
158 | - $this->assertTrue($result); |
|
156 | + //check with a invalid value |
|
157 | + $result = $SugarController->checkEntryPointRequiresAuth(''); |
|
158 | + $this->assertTrue($result); |
|
159 | 159 | |
160 | - //cehck with a valid True value |
|
161 | - $result = $SugarController->checkEntryPointRequiresAuth('download'); |
|
162 | - $this->assertTrue($result); |
|
160 | + //cehck with a valid True value |
|
161 | + $result = $SugarController->checkEntryPointRequiresAuth('download'); |
|
162 | + $this->assertTrue($result); |
|
163 | 163 | |
164 | - //cehck with a valid False value |
|
165 | - $result = $SugarController->checkEntryPointRequiresAuth('GeneratePassword'); |
|
166 | - $this->assertFalse($result); |
|
164 | + //cehck with a valid False value |
|
165 | + $result = $SugarController->checkEntryPointRequiresAuth('GeneratePassword'); |
|
166 | + $this->assertFalse($result); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 |
@@ -4,123 +4,123 @@ |
||
4 | 4 | class security_utilsTest extends PHPUnit_Framework_TestCase |
5 | 5 | { |
6 | 6 | |
7 | - public function testquery_module_access_list() |
|
8 | - { |
|
7 | + public function testquery_module_access_list() |
|
8 | + { |
|
9 | 9 | |
10 | - //execute the method and test it it returns expected contents |
|
10 | + //execute the method and test it it returns expected contents |
|
11 | 11 | |
12 | - $user = new User('1'); |
|
13 | - $expected = array ( |
|
14 | - 'Home' => 'Home', |
|
15 | - 'Accounts' => 'Accounts', |
|
16 | - 'Contacts' => 'Contacts', |
|
17 | - 'Opportunities' => 'Opportunities', |
|
18 | - 'Leads' => 'Leads', |
|
19 | - 'AOS_Quotes' => 'AOS_Quotes', |
|
20 | - 'Calendar' => 'Calendar', |
|
21 | - 'Documents' => 'Documents', |
|
22 | - 'Emails' => 'Emails', |
|
23 | - 'Campaigns' => 'Campaigns', |
|
24 | - 'Calls' => 'Calls', |
|
25 | - 'Meetings' => 'Meetings', |
|
26 | - 'Tasks' => 'Tasks', |
|
27 | - 'Notes' => 'Notes', |
|
28 | - 'AOS_Invoices' => 'AOS_Invoices', |
|
29 | - 'AOS_Contracts' => 'AOS_Contracts', |
|
30 | - 'Cases' => 'Cases', |
|
31 | - 'Prospects' => 'Prospects', |
|
32 | - 'ProspectLists' => 'ProspectLists', |
|
33 | - 'Project' => 'Project', |
|
34 | - 'AM_ProjectTemplates' => 'AM_ProjectTemplates', |
|
35 | - 'FP_events' => 'FP_events', |
|
36 | - 'FP_Event_Locations' => 'FP_Event_Locations', |
|
37 | - 'AOS_Products' => 'AOS_Products', |
|
38 | - 'AOS_Product_Categories' => 'AOS_Product_Categories', |
|
39 | - 'AOS_PDF_Templates' => 'AOS_PDF_Templates', |
|
40 | - 'jjwg_Maps' => 'jjwg_Maps', |
|
41 | - 'jjwg_Markers' => 'jjwg_Markers', |
|
42 | - 'jjwg_Areas' => 'jjwg_Areas', |
|
43 | - 'jjwg_Address_Cache' => 'jjwg_Address_Cache', |
|
44 | - 'AOR_Reports' => 'AOR_Reports', |
|
45 | - 'AOW_WorkFlow' => 'AOW_WorkFlow', |
|
46 | - 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', |
|
47 | - 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', |
|
48 | - ); |
|
12 | + $user = new User('1'); |
|
13 | + $expected = array ( |
|
14 | + 'Home' => 'Home', |
|
15 | + 'Accounts' => 'Accounts', |
|
16 | + 'Contacts' => 'Contacts', |
|
17 | + 'Opportunities' => 'Opportunities', |
|
18 | + 'Leads' => 'Leads', |
|
19 | + 'AOS_Quotes' => 'AOS_Quotes', |
|
20 | + 'Calendar' => 'Calendar', |
|
21 | + 'Documents' => 'Documents', |
|
22 | + 'Emails' => 'Emails', |
|
23 | + 'Campaigns' => 'Campaigns', |
|
24 | + 'Calls' => 'Calls', |
|
25 | + 'Meetings' => 'Meetings', |
|
26 | + 'Tasks' => 'Tasks', |
|
27 | + 'Notes' => 'Notes', |
|
28 | + 'AOS_Invoices' => 'AOS_Invoices', |
|
29 | + 'AOS_Contracts' => 'AOS_Contracts', |
|
30 | + 'Cases' => 'Cases', |
|
31 | + 'Prospects' => 'Prospects', |
|
32 | + 'ProspectLists' => 'ProspectLists', |
|
33 | + 'Project' => 'Project', |
|
34 | + 'AM_ProjectTemplates' => 'AM_ProjectTemplates', |
|
35 | + 'FP_events' => 'FP_events', |
|
36 | + 'FP_Event_Locations' => 'FP_Event_Locations', |
|
37 | + 'AOS_Products' => 'AOS_Products', |
|
38 | + 'AOS_Product_Categories' => 'AOS_Product_Categories', |
|
39 | + 'AOS_PDF_Templates' => 'AOS_PDF_Templates', |
|
40 | + 'jjwg_Maps' => 'jjwg_Maps', |
|
41 | + 'jjwg_Markers' => 'jjwg_Markers', |
|
42 | + 'jjwg_Areas' => 'jjwg_Areas', |
|
43 | + 'jjwg_Address_Cache' => 'jjwg_Address_Cache', |
|
44 | + 'AOR_Reports' => 'AOR_Reports', |
|
45 | + 'AOW_WorkFlow' => 'AOW_WorkFlow', |
|
46 | + 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', |
|
47 | + 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', |
|
48 | + ); |
|
49 | 49 | |
50 | - $actual = query_module_access_list($user); |
|
51 | - $this->assertSame($expected,$actual); |
|
50 | + $actual = query_module_access_list($user); |
|
51 | + $this->assertSame($expected,$actual); |
|
52 | 52 | |
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - public function testquery_user_has_roles() |
|
57 | - { |
|
58 | - error_reporting(E_ERROR | E_PARSE); |
|
56 | + public function testquery_user_has_roles() |
|
57 | + { |
|
58 | + error_reporting(E_ERROR | E_PARSE); |
|
59 | 59 | |
60 | - //execute the method and test it it returns expected contents |
|
60 | + //execute the method and test it it returns expected contents |
|
61 | 61 | |
62 | - $expected = "0"; |
|
63 | - $actual = query_user_has_roles('1'); |
|
64 | - $this->assertSame($expected,$actual); |
|
62 | + $expected = "0"; |
|
63 | + $actual = query_user_has_roles('1'); |
|
64 | + $this->assertSame($expected,$actual); |
|
65 | 65 | |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | - public function testget_user_allowed_modules() |
|
69 | - { |
|
70 | - //execute the method and test it it returns expected contents |
|
68 | + public function testget_user_allowed_modules() |
|
69 | + { |
|
70 | + //execute the method and test it it returns expected contents |
|
71 | 71 | |
72 | - $expected = Array(); |
|
73 | - $actual = get_user_allowed_modules('1'); |
|
74 | - $this->assertSame($expected,$actual); |
|
72 | + $expected = Array(); |
|
73 | + $actual = get_user_allowed_modules('1'); |
|
74 | + $this->assertSame($expected,$actual); |
|
75 | 75 | |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - public function testget_user_disallowed_modules() |
|
79 | - { |
|
80 | - //execute the method and test it it returns expected contents |
|
78 | + public function testget_user_disallowed_modules() |
|
79 | + { |
|
80 | + //execute the method and test it it returns expected contents |
|
81 | 81 | |
82 | - $expected = array ( |
|
83 | - 'Bugs' => 'Bugs', |
|
82 | + $expected = array ( |
|
83 | + 'Bugs' => 'Bugs', |
|
84 | 84 | 'Reminders' => 'Reminders', |
85 | 85 | 'Reminders_Invitees' => 'Reminders_Invitees', |
86 | - 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', |
|
87 | - 'SecurityGroups' => 'SecurityGroups', |
|
88 | - ); |
|
86 | + 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', |
|
87 | + 'SecurityGroups' => 'SecurityGroups', |
|
88 | + ); |
|
89 | 89 | |
90 | - $allowed = query_module_access_list(new User('1')); |
|
91 | - $actual = get_user_disallowed_modules('1',$allowed); |
|
90 | + $allowed = query_module_access_list(new User('1')); |
|
91 | + $actual = get_user_disallowed_modules('1',$allowed); |
|
92 | 92 | |
93 | - $this->assertSame($expected,$actual); |
|
93 | + $this->assertSame($expected,$actual); |
|
94 | 94 | |
95 | 95 | |
96 | - } |
|
96 | + } |
|
97 | 97 | |
98 | - public function testquery_client_ip() |
|
99 | - { |
|
100 | - //test without setting any server parameters |
|
101 | - $this->assertSame(Null,query_client_ip()); |
|
98 | + public function testquery_client_ip() |
|
99 | + { |
|
100 | + //test without setting any server parameters |
|
101 | + $this->assertSame(Null,query_client_ip()); |
|
102 | 102 | |
103 | - //test with server params set |
|
104 | - $_SERVER['REMOTE_ADDR'] = "1.1.1.3"; |
|
105 | - $this->assertSame("1.1.1.3",query_client_ip()); |
|
103 | + //test with server params set |
|
104 | + $_SERVER['REMOTE_ADDR'] = "1.1.1.3"; |
|
105 | + $this->assertSame("1.1.1.3",query_client_ip()); |
|
106 | 106 | |
107 | - $_SERVER['HTTP_FROM'] = "1.1.1.2"; |
|
108 | - $this->assertSame("1.1.1.2",query_client_ip()); |
|
107 | + $_SERVER['HTTP_FROM'] = "1.1.1.2"; |
|
108 | + $this->assertSame("1.1.1.2",query_client_ip()); |
|
109 | 109 | |
110 | - $_SERVER['HTTP_CLIENT_IP'] = "1.1.1.1"; |
|
111 | - $this->assertSame("1.1.1.1",query_client_ip()); |
|
110 | + $_SERVER['HTTP_CLIENT_IP'] = "1.1.1.1"; |
|
111 | + $this->assertSame("1.1.1.1",query_client_ip()); |
|
112 | 112 | |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - public function testget_val_array() |
|
117 | - { |
|
118 | - //execute the method and test it it returns expected contents |
|
119 | - $tempArray = Array("key1"=>"val1","key2"=>"val2","key3"=>"val3"); |
|
120 | - $expected = Array("key1"=>"key1","key2"=>"key2","key3"=>"key3"); |
|
121 | - $actual = get_val_array($tempArray); |
|
122 | - $this->assertSame($expected,$actual); |
|
116 | + public function testget_val_array() |
|
117 | + { |
|
118 | + //execute the method and test it it returns expected contents |
|
119 | + $tempArray = Array("key1"=>"val1","key2"=>"val2","key3"=>"val3"); |
|
120 | + $expected = Array("key1"=>"key1","key2"=>"key2","key3"=>"key3"); |
|
121 | + $actual = get_val_array($tempArray); |
|
122 | + $this->assertSame($expected,$actual); |
|
123 | 123 | |
124 | - } |
|
124 | + } |
|
125 | 125 | |
126 | 126 | } |
@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | |
16 | 16 | |
17 | 17 | public function testclean_path() |
18 | - { |
|
19 | - //execute the method and test if it returns expected values |
|
18 | + { |
|
19 | + //execute the method and test if it returns expected values |
|
20 | 20 | |
21 | - //invalid path |
|
22 | - $expected = ""; |
|
23 | - $path = ""; |
|
24 | - $actual = clean_path($path); |
|
25 | - $this->assertSame($expected,$actual); |
|
21 | + //invalid path |
|
22 | + $expected = ""; |
|
23 | + $path = ""; |
|
24 | + $actual = clean_path($path); |
|
25 | + $this->assertSame($expected,$actual); |
|
26 | 26 | |
27 | 27 | |
28 | - //a simple valid path |
|
29 | - $expected = "/SuiteCRM-develop/include/utils"; |
|
30 | - $path = '\SuiteCRM-develop\include\utils'; |
|
31 | - $actual = clean_path($path); |
|
32 | - $this->assertSame($expected,$actual); |
|
28 | + //a simple valid path |
|
29 | + $expected = "/SuiteCRM-develop/include/utils"; |
|
30 | + $path = '\SuiteCRM-develop\include\utils'; |
|
31 | + $actual = clean_path($path); |
|
32 | + $this->assertSame($expected,$actual); |
|
33 | 33 | |
34 | 34 | |
35 | - //valid network path |
|
36 | - $expected = "//SuiteCRM-develop/include/utils"; |
|
37 | - $path = "\\\\/SuiteCRM-develop/include/utils"; |
|
38 | - $actual = clean_path($path); |
|
39 | - $this->assertSame($expected,$actual); |
|
35 | + //valid network path |
|
36 | + $expected = "//SuiteCRM-develop/include/utils"; |
|
37 | + $path = "\\\\/SuiteCRM-develop/include/utils"; |
|
38 | + $actual = clean_path($path); |
|
39 | + $this->assertSame($expected,$actual); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | $expected = "/SuiteCRM-develop/include/utils"; |
@@ -51,474 +51,474 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | - public function testcreate_cache_directory() |
|
57 | - { |
|
58 | - //execute the method and test if it created file/dir exists |
|
56 | + public function testcreate_cache_directory() |
|
57 | + { |
|
58 | + //execute the method and test if it created file/dir exists |
|
59 | 59 | |
60 | - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
|
61 | - $file = "Test/"; |
|
60 | + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
|
61 | + $file = "Test/"; |
|
62 | 62 | |
63 | - if ( $this->rootFs->hasChild($file) == true) |
|
64 | - rmdir($cache_dir . "/" . $file); |
|
63 | + if ( $this->rootFs->hasChild($file) == true) |
|
64 | + rmdir($cache_dir . "/" . $file); |
|
65 | 65 | |
66 | - $actual = create_cache_directory($file); |
|
67 | - $this->assertFileExists($actual); |
|
66 | + $actual = create_cache_directory($file); |
|
67 | + $this->assertFileExists($actual); |
|
68 | 68 | |
69 | - if ( $this->rootFs->hasChild($file) == true) |
|
70 | - rmdir($cache_dir . "/" . $file); |
|
69 | + if ( $this->rootFs->hasChild($file) == true) |
|
70 | + rmdir($cache_dir . "/" . $file); |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - public function testget_module_dir_list() |
|
75 | - { |
|
76 | - //execute the method and test if it returns expected values |
|
77 | - |
|
78 | - $expected = array ( |
|
79 | - 'Accounts' => 'Accounts', |
|
80 | - 'ACL' => 'ACL', |
|
81 | - 'ACLActions' => 'ACLActions', |
|
82 | - 'ACLRoles' => 'ACLRoles', |
|
83 | - 'Activities' => 'Activities', |
|
84 | - 'Administration' => 'Administration', |
|
85 | - 'Alerts' => 'Alerts', |
|
86 | - 'AM_ProjectTemplates' => 'AM_ProjectTemplates', |
|
87 | - 'AM_TaskTemplates' => 'AM_TaskTemplates', |
|
88 | - 'AOD_Index' => 'AOD_Index', |
|
89 | - 'AOD_IndexEvent' => 'AOD_IndexEvent', |
|
90 | - 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', |
|
91 | - 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', |
|
92 | - 'AOP_Case_Events' => 'AOP_Case_Events', |
|
93 | - 'AOP_Case_Updates' => 'AOP_Case_Updates', |
|
94 | - 'AOR_Charts' => 'AOR_Charts', |
|
95 | - 'AOR_Conditions' => 'AOR_Conditions', |
|
96 | - 'AOR_Fields' => 'AOR_Fields', |
|
97 | - 'AOR_Reports' => 'AOR_Reports', |
|
98 | - 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', |
|
99 | - 'AOS_Contracts' => 'AOS_Contracts', |
|
100 | - 'AOS_Invoices' => 'AOS_Invoices', |
|
101 | - 'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups', |
|
102 | - 'AOS_PDF_Templates' => 'AOS_PDF_Templates', |
|
103 | - 'AOS_Products' => 'AOS_Products', |
|
104 | - 'AOS_Products_Quotes' => 'AOS_Products_Quotes', |
|
105 | - 'AOS_Product_Categories' => 'AOS_Product_Categories', |
|
106 | - 'AOS_Quotes' => 'AOS_Quotes', |
|
107 | - 'AOW_Actions' => 'AOW_Actions', |
|
108 | - 'AOW_Conditions' => 'AOW_Conditions', |
|
109 | - 'AOW_Processed' => 'AOW_Processed', |
|
110 | - 'AOW_WorkFlow' => 'AOW_WorkFlow', |
|
111 | - 'Audit' => 'Audit', |
|
112 | - 'Bugs' => 'Bugs', |
|
113 | - 'Calendar' => 'Calendar', |
|
114 | - 'Calls' => 'Calls', |
|
115 | - 'Calls_Reschedule' => 'Calls_Reschedule', |
|
116 | - 'CampaignLog' => 'CampaignLog', |
|
117 | - 'Campaigns' => 'Campaigns', |
|
118 | - 'CampaignTrackers' => 'CampaignTrackers', |
|
119 | - 'Cases' => 'Cases', |
|
120 | - 'Charts' => 'Charts', |
|
121 | - 'Configurator' => 'Configurator', |
|
122 | - 'Connectors' => 'Connectors', |
|
123 | - 'Contacts' => 'Contacts', |
|
124 | - 'Currencies' => 'Currencies', |
|
125 | - 'Delegates' => 'Delegates', |
|
126 | - 'DocumentRevisions' => 'DocumentRevisions', |
|
127 | - 'Documents' => 'Documents', |
|
128 | - 'DynamicFields' => 'DynamicFields', |
|
129 | - 'EAPM' => 'EAPM', |
|
130 | - 'EmailAddresses' => 'EmailAddresses', |
|
131 | - 'EmailMan' => 'EmailMan', |
|
132 | - 'EmailMarketing' => 'EmailMarketing', |
|
133 | - 'Emails' => 'Emails', |
|
134 | - 'EmailTemplates' => 'EmailTemplates', |
|
135 | - 'EmailText' => 'EmailText', |
|
136 | - 'Employees' => 'Employees', |
|
137 | - 'Favorites' => 'Favorites', |
|
138 | - 'FP_events' => 'FP_events', |
|
139 | - 'FP_Event_Locations' => 'FP_Event_Locations', |
|
140 | - 'Groups' => 'Groups', |
|
141 | - 'Help' => 'Help', |
|
142 | - 'History' => 'History', |
|
143 | - 'Home' => 'Home', |
|
144 | - 'iCals' => 'iCals', |
|
145 | - 'Import' => 'Import', |
|
146 | - 'InboundEmail' => 'InboundEmail', |
|
147 | - 'jjwg_Address_Cache' => 'jjwg_Address_Cache', |
|
148 | - 'jjwg_Areas' => 'jjwg_Areas', |
|
149 | - 'jjwg_Maps' => 'jjwg_Maps', |
|
150 | - 'jjwg_Markers' => 'jjwg_Markers', |
|
151 | - 'LabelEditor' => 'LabelEditor', |
|
152 | - 'Leads' => 'Leads', |
|
153 | - 'MailMerge' => 'MailMerge', |
|
154 | - 'Meetings' => 'Meetings', |
|
155 | - 'MergeRecords' => 'MergeRecords', |
|
156 | - 'ModuleBuilder' => 'ModuleBuilder', |
|
157 | - 'MySettings' => 'MySettings', |
|
158 | - 'Notes' => 'Notes', |
|
159 | - 'OAuthKeys' => 'OAuthKeys', |
|
160 | - 'OAuthTokens' => 'OAuthTokens', |
|
161 | - 'Opportunities' => 'Opportunities', |
|
162 | - 'OptimisticLock' => 'OptimisticLock', |
|
163 | - 'Project' => 'Project', |
|
164 | - 'ProjectTask' => 'ProjectTask', |
|
165 | - 'ProspectLists' => 'ProspectLists', |
|
166 | - 'Prospects' => 'Prospects', |
|
167 | - 'Relationships' => 'Relationships', |
|
74 | + public function testget_module_dir_list() |
|
75 | + { |
|
76 | + //execute the method and test if it returns expected values |
|
77 | + |
|
78 | + $expected = array ( |
|
79 | + 'Accounts' => 'Accounts', |
|
80 | + 'ACL' => 'ACL', |
|
81 | + 'ACLActions' => 'ACLActions', |
|
82 | + 'ACLRoles' => 'ACLRoles', |
|
83 | + 'Activities' => 'Activities', |
|
84 | + 'Administration' => 'Administration', |
|
85 | + 'Alerts' => 'Alerts', |
|
86 | + 'AM_ProjectTemplates' => 'AM_ProjectTemplates', |
|
87 | + 'AM_TaskTemplates' => 'AM_TaskTemplates', |
|
88 | + 'AOD_Index' => 'AOD_Index', |
|
89 | + 'AOD_IndexEvent' => 'AOD_IndexEvent', |
|
90 | + 'AOK_KnowledgeBase' => 'AOK_KnowledgeBase', |
|
91 | + 'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories', |
|
92 | + 'AOP_Case_Events' => 'AOP_Case_Events', |
|
93 | + 'AOP_Case_Updates' => 'AOP_Case_Updates', |
|
94 | + 'AOR_Charts' => 'AOR_Charts', |
|
95 | + 'AOR_Conditions' => 'AOR_Conditions', |
|
96 | + 'AOR_Fields' => 'AOR_Fields', |
|
97 | + 'AOR_Reports' => 'AOR_Reports', |
|
98 | + 'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports', |
|
99 | + 'AOS_Contracts' => 'AOS_Contracts', |
|
100 | + 'AOS_Invoices' => 'AOS_Invoices', |
|
101 | + 'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups', |
|
102 | + 'AOS_PDF_Templates' => 'AOS_PDF_Templates', |
|
103 | + 'AOS_Products' => 'AOS_Products', |
|
104 | + 'AOS_Products_Quotes' => 'AOS_Products_Quotes', |
|
105 | + 'AOS_Product_Categories' => 'AOS_Product_Categories', |
|
106 | + 'AOS_Quotes' => 'AOS_Quotes', |
|
107 | + 'AOW_Actions' => 'AOW_Actions', |
|
108 | + 'AOW_Conditions' => 'AOW_Conditions', |
|
109 | + 'AOW_Processed' => 'AOW_Processed', |
|
110 | + 'AOW_WorkFlow' => 'AOW_WorkFlow', |
|
111 | + 'Audit' => 'Audit', |
|
112 | + 'Bugs' => 'Bugs', |
|
113 | + 'Calendar' => 'Calendar', |
|
114 | + 'Calls' => 'Calls', |
|
115 | + 'Calls_Reschedule' => 'Calls_Reschedule', |
|
116 | + 'CampaignLog' => 'CampaignLog', |
|
117 | + 'Campaigns' => 'Campaigns', |
|
118 | + 'CampaignTrackers' => 'CampaignTrackers', |
|
119 | + 'Cases' => 'Cases', |
|
120 | + 'Charts' => 'Charts', |
|
121 | + 'Configurator' => 'Configurator', |
|
122 | + 'Connectors' => 'Connectors', |
|
123 | + 'Contacts' => 'Contacts', |
|
124 | + 'Currencies' => 'Currencies', |
|
125 | + 'Delegates' => 'Delegates', |
|
126 | + 'DocumentRevisions' => 'DocumentRevisions', |
|
127 | + 'Documents' => 'Documents', |
|
128 | + 'DynamicFields' => 'DynamicFields', |
|
129 | + 'EAPM' => 'EAPM', |
|
130 | + 'EmailAddresses' => 'EmailAddresses', |
|
131 | + 'EmailMan' => 'EmailMan', |
|
132 | + 'EmailMarketing' => 'EmailMarketing', |
|
133 | + 'Emails' => 'Emails', |
|
134 | + 'EmailTemplates' => 'EmailTemplates', |
|
135 | + 'EmailText' => 'EmailText', |
|
136 | + 'Employees' => 'Employees', |
|
137 | + 'Favorites' => 'Favorites', |
|
138 | + 'FP_events' => 'FP_events', |
|
139 | + 'FP_Event_Locations' => 'FP_Event_Locations', |
|
140 | + 'Groups' => 'Groups', |
|
141 | + 'Help' => 'Help', |
|
142 | + 'History' => 'History', |
|
143 | + 'Home' => 'Home', |
|
144 | + 'iCals' => 'iCals', |
|
145 | + 'Import' => 'Import', |
|
146 | + 'InboundEmail' => 'InboundEmail', |
|
147 | + 'jjwg_Address_Cache' => 'jjwg_Address_Cache', |
|
148 | + 'jjwg_Areas' => 'jjwg_Areas', |
|
149 | + 'jjwg_Maps' => 'jjwg_Maps', |
|
150 | + 'jjwg_Markers' => 'jjwg_Markers', |
|
151 | + 'LabelEditor' => 'LabelEditor', |
|
152 | + 'Leads' => 'Leads', |
|
153 | + 'MailMerge' => 'MailMerge', |
|
154 | + 'Meetings' => 'Meetings', |
|
155 | + 'MergeRecords' => 'MergeRecords', |
|
156 | + 'ModuleBuilder' => 'ModuleBuilder', |
|
157 | + 'MySettings' => 'MySettings', |
|
158 | + 'Notes' => 'Notes', |
|
159 | + 'OAuthKeys' => 'OAuthKeys', |
|
160 | + 'OAuthTokens' => 'OAuthTokens', |
|
161 | + 'Opportunities' => 'Opportunities', |
|
162 | + 'OptimisticLock' => 'OptimisticLock', |
|
163 | + 'Project' => 'Project', |
|
164 | + 'ProjectTask' => 'ProjectTask', |
|
165 | + 'ProspectLists' => 'ProspectLists', |
|
166 | + 'Prospects' => 'Prospects', |
|
167 | + 'Relationships' => 'Relationships', |
|
168 | 168 | 'Reminders' => 'Reminders', |
169 | 169 | 'Reminders_Invitees' => 'Reminders_Invitees', |
170 | - 'Releases' => 'Releases', |
|
171 | - 'Roles' => 'Roles', |
|
172 | - 'SavedSearch' => 'SavedSearch', |
|
173 | - 'Schedulers' => 'Schedulers', |
|
174 | - 'SchedulersJobs' => 'SchedulersJobs', |
|
175 | - 'SecurityGroups' => 'SecurityGroups', |
|
176 | - 'Studio' => 'Studio', |
|
177 | - 'SugarFeed' => 'SugarFeed', |
|
178 | - 'Tasks' => 'Tasks', |
|
179 | - 'Trackers' => 'Trackers', |
|
180 | - 'UpgradeWizard' => 'UpgradeWizard', |
|
181 | - 'UserPreferences' => 'UserPreferences', |
|
182 | - 'Users' => 'Users', |
|
183 | - 'vCals' => 'vCals', |
|
184 | - 'Versions' => 'Versions', |
|
185 | - ); |
|
186 | - |
|
187 | - |
|
188 | - $actual = get_module_dir_list(); |
|
170 | + 'Releases' => 'Releases', |
|
171 | + 'Roles' => 'Roles', |
|
172 | + 'SavedSearch' => 'SavedSearch', |
|
173 | + 'Schedulers' => 'Schedulers', |
|
174 | + 'SchedulersJobs' => 'SchedulersJobs', |
|
175 | + 'SecurityGroups' => 'SecurityGroups', |
|
176 | + 'Studio' => 'Studio', |
|
177 | + 'SugarFeed' => 'SugarFeed', |
|
178 | + 'Tasks' => 'Tasks', |
|
179 | + 'Trackers' => 'Trackers', |
|
180 | + 'UpgradeWizard' => 'UpgradeWizard', |
|
181 | + 'UserPreferences' => 'UserPreferences', |
|
182 | + 'Users' => 'Users', |
|
183 | + 'vCals' => 'vCals', |
|
184 | + 'Versions' => 'Versions', |
|
185 | + ); |
|
186 | + |
|
187 | + |
|
188 | + $actual = get_module_dir_list(); |
|
189 | 189 | sort($actual); |
190 | 190 | sort($expected); |
191 | - $this->assertSame($expected,$actual); |
|
191 | + $this->assertSame($expected,$actual); |
|
192 | 192 | |
193 | - } |
|
193 | + } |
|
194 | 194 | |
195 | - public function testmk_temp_dir( ) |
|
196 | - { |
|
197 | - //execute the method and test if created dir/file exists |
|
195 | + public function testmk_temp_dir( ) |
|
196 | + { |
|
197 | + //execute the method and test if created dir/file exists |
|
198 | 198 | |
199 | - //without prefix |
|
200 | - $actual = mk_temp_dir('vfs://root', '' ); |
|
201 | - $this->assertFileExists($actual); |
|
199 | + //without prefix |
|
200 | + $actual = mk_temp_dir('vfs://root', '' ); |
|
201 | + $this->assertFileExists($actual); |
|
202 | 202 | |
203 | - //with prefix |
|
204 | - $actual = mk_temp_dir('vfs://root', 'pfx' ); |
|
205 | - $this->assertFileExists($actual); |
|
203 | + //with prefix |
|
204 | + $actual = mk_temp_dir('vfs://root', 'pfx' ); |
|
205 | + $this->assertFileExists($actual); |
|
206 | 206 | |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - public function testremove_file_extension( ) |
|
210 | - { |
|
211 | - //execute the method and test if it returns expected values |
|
209 | + public function testremove_file_extension( ) |
|
210 | + { |
|
211 | + //execute the method and test if it returns expected values |
|
212 | 212 | |
213 | - //no file extension |
|
214 | - $expected = ""; |
|
215 | - $actual = remove_file_extension('fileNoExt'); |
|
216 | - $this->assertSame($expected,$actual); |
|
213 | + //no file extension |
|
214 | + $expected = ""; |
|
215 | + $actual = remove_file_extension('fileNoExt'); |
|
216 | + $this->assertSame($expected,$actual); |
|
217 | 217 | |
218 | 218 | |
219 | - //simple file extension |
|
220 | - $expected = "file1"; |
|
221 | - $actual = remove_file_extension('file1.txt'); |
|
222 | - $this->assertSame($expected,$actual); |
|
219 | + //simple file extension |
|
220 | + $expected = "file1"; |
|
221 | + $actual = remove_file_extension('file1.txt'); |
|
222 | + $this->assertSame($expected,$actual); |
|
223 | 223 | |
224 | 224 | |
225 | - //complex filename |
|
226 | - $expected = "file2.ext1"; |
|
227 | - $actual = remove_file_extension('file2.ext1.ext2'); |
|
228 | - $this->assertSame($expected,$actual); |
|
225 | + //complex filename |
|
226 | + $expected = "file2.ext1"; |
|
227 | + $actual = remove_file_extension('file2.ext1.ext2'); |
|
228 | + $this->assertSame($expected,$actual); |
|
229 | 229 | |
230 | - } |
|
230 | + } |
|
231 | 231 | |
232 | - public function testwrite_array_to_file() |
|
233 | - { |
|
232 | + public function testwrite_array_to_file() |
|
233 | + { |
|
234 | 234 | $this->markTestSkipped('write_array_to_file cannot be tested with vfsStream'); |
235 | - //execute the method and test if it returns true and verify contents |
|
235 | + //execute the method and test if it returns true and verify contents |
|
236 | 236 | |
237 | - $cache_dir = "vfs://root"; |
|
238 | - $tempArray = Array("Key1" => Array( "Key2" => "value2" , "Key3" => "value3" )); |
|
237 | + $cache_dir = "vfs://root"; |
|
238 | + $tempArray = Array("Key1" => Array( "Key2" => "value2" , "Key3" => "value3" )); |
|
239 | 239 | |
240 | 240 | |
241 | - //without header |
|
242 | - $expected = "<?php\n// created: " . date('Y-m-d H:i:s') . "\n\$tempArray = array (\n 'Key1' => \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);" ; |
|
243 | - $actual = write_array_to_file('tempArray', $tempArray, $cache_dir . '\tempArray.txt'); |
|
244 | - $this->assertTrue($actual); |
|
245 | - $actual_contents = file_get_contents($cache_dir . '\tempArray.txt'); |
|
246 | - $this->assertSame($expected,$actual_contents); |
|
247 | - unlink($cache_dir . '\tempArray.txt'); |
|
241 | + //without header |
|
242 | + $expected = "<?php\n// created: " . date('Y-m-d H:i:s') . "\n\$tempArray = array (\n 'Key1' => \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);" ; |
|
243 | + $actual = write_array_to_file('tempArray', $tempArray, $cache_dir . '\tempArray.txt'); |
|
244 | + $this->assertTrue($actual); |
|
245 | + $actual_contents = file_get_contents($cache_dir . '\tempArray.txt'); |
|
246 | + $this->assertSame($expected,$actual_contents); |
|
247 | + unlink($cache_dir . '\tempArray.txt'); |
|
248 | 248 | |
249 | - //with header |
|
250 | - $expected = "test header \$tempArray = array (\n 'Key1' => \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);" ; |
|
251 | - $actual = write_array_to_file('tempArray', $tempArray, $cache_dir . '\tempArray.txt','w' ,'test header '); |
|
252 | - $this->assertTrue($actual); |
|
253 | - $actual_contents = file_get_contents($cache_dir . '\tempArray.txt'); |
|
254 | - $this->assertSame($expected,$actual_contents); |
|
255 | - unlink($cache_dir . '\tempArray.txt'); |
|
249 | + //with header |
|
250 | + $expected = "test header \$tempArray = array (\n 'Key1' => \n array (\n 'Key2' => 'value2',\n 'Key3' => 'value3',\n ),\n);" ; |
|
251 | + $actual = write_array_to_file('tempArray', $tempArray, $cache_dir . '\tempArray.txt','w' ,'test header '); |
|
252 | + $this->assertTrue($actual); |
|
253 | + $actual_contents = file_get_contents($cache_dir . '\tempArray.txt'); |
|
254 | + $this->assertSame($expected,$actual_contents); |
|
255 | + unlink($cache_dir . '\tempArray.txt'); |
|
256 | 256 | |
257 | 257 | |
258 | - } |
|
258 | + } |
|
259 | 259 | |
260 | - public function testwrite_encoded_file( ) |
|
261 | - { |
|
262 | - //execute the method and test if it created file exists |
|
260 | + public function testwrite_encoded_file( ) |
|
261 | + { |
|
262 | + //execute the method and test if it created file exists |
|
263 | 263 | |
264 | - $cache_dir = "vfs://root"; |
|
264 | + $cache_dir = "vfs://root"; |
|
265 | 265 | |
266 | - //without filename |
|
267 | - $tempArray = Array("filename" =>'soap_array.txt' , "md5" => "523ef67de860fc54794f27117dba4fac" , "data" => "some soap data" ); |
|
268 | - $actual = write_encoded_file( $tempArray, $cache_dir, "" ); |
|
269 | - $this->assertFileExists($actual); |
|
270 | - unlink($actual); |
|
266 | + //without filename |
|
267 | + $tempArray = Array("filename" =>'soap_array.txt' , "md5" => "523ef67de860fc54794f27117dba4fac" , "data" => "some soap data" ); |
|
268 | + $actual = write_encoded_file( $tempArray, $cache_dir, "" ); |
|
269 | + $this->assertFileExists($actual); |
|
270 | + unlink($actual); |
|
271 | 271 | |
272 | 272 | |
273 | - //with filename |
|
274 | - $tempArray = Array("md5" => "523ef67de860fc54794f27117dba4fac" , "data" => "some soap data" ); |
|
275 | - $actual = write_encoded_file( $tempArray, $cache_dir, "soap_array.txt" ); |
|
276 | - $this->assertFileExists($actual); |
|
277 | - unlink($actual); |
|
273 | + //with filename |
|
274 | + $tempArray = Array("md5" => "523ef67de860fc54794f27117dba4fac" , "data" => "some soap data" ); |
|
275 | + $actual = write_encoded_file( $tempArray, $cache_dir, "soap_array.txt" ); |
|
276 | + $this->assertFileExists($actual); |
|
277 | + unlink($actual); |
|
278 | 278 | |
279 | - } |
|
279 | + } |
|
280 | 280 | |
281 | - public function testcreate_custom_directory() |
|
282 | - { |
|
283 | - //execute the method and test if it created file/dir exists |
|
281 | + public function testcreate_custom_directory() |
|
282 | + { |
|
283 | + //execute the method and test if it created file/dir exists |
|
284 | 284 | |
285 | - $file = "Test/"; |
|
285 | + $file = "Test/"; |
|
286 | 286 | |
287 | - $vfs = $this->rootFs; |
|
288 | - if ( $vfs->hasChild($file) == true) |
|
289 | - rmdir("custom/" . $file); |
|
287 | + $vfs = $this->rootFs; |
|
288 | + if ( $vfs->hasChild($file) == true) |
|
289 | + rmdir("custom/" . $file); |
|
290 | 290 | |
291 | - $actual = create_custom_directory($file); |
|
292 | - $this->assertFileExists($actual); |
|
291 | + $actual = create_custom_directory($file); |
|
292 | + $this->assertFileExists($actual); |
|
293 | 293 | |
294 | - if ( $vfs->hasChild($file) == true) |
|
295 | - rmdir("custom/" . $file); |
|
294 | + if ( $vfs->hasChild($file) == true) |
|
295 | + rmdir("custom/" . $file); |
|
296 | 296 | |
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | 300 | |
301 | - public function testgenerateMD5array() |
|
302 | - { |
|
303 | - //execute the method and test if it returns expected values |
|
301 | + public function testgenerateMD5array() |
|
302 | + { |
|
303 | + //execute the method and test if it returns expected values |
|
304 | 304 | |
305 | - $expected= array ( |
|
306 | - 'data/Relationships/EmailAddressRelationship.php' => '2f04780ddd15f7b65a35c75c303ed5d7', |
|
307 | - 'data/Relationships/M2MRelationship.php' => 'c320909b5a17d63aafa0d7497fe3c991', |
|
308 | - 'data/Relationships/One2MBeanRelationship.php' => 'c09fe92826b4c8a3944694098de35027', |
|
309 | - 'data/Relationships/One2MRelationship.php' => '588ad87910bd9d885fe27da77ad13e30', |
|
310 | - 'data/Relationships/One2OneBeanRelationship.php' => '765b8785d5ca576a8530db99bdf4d411', |
|
311 | - 'data/Relationships/One2OneRelationship.php' => '0385f7577687a402d9603ef26984257e', |
|
312 | - 'data/Relationships/RelationshipFactory.php' => '3bd7cc6998beaf82a13808f54bff1c2d', |
|
313 | - 'data/Relationships/SugarRelationship.php' => '8d0fa8ae0f41ac34eb5d0c04f0e02825', |
|
314 | - ); |
|
315 | - |
|
316 | - $actual = generateMD5array('data/Relationships/'); |
|
317 | - $this->assertSame($expected,$actual); |
|
305 | + $expected= array ( |
|
306 | + 'data/Relationships/EmailAddressRelationship.php' => '2f04780ddd15f7b65a35c75c303ed5d7', |
|
307 | + 'data/Relationships/M2MRelationship.php' => 'c320909b5a17d63aafa0d7497fe3c991', |
|
308 | + 'data/Relationships/One2MBeanRelationship.php' => 'c09fe92826b4c8a3944694098de35027', |
|
309 | + 'data/Relationships/One2MRelationship.php' => '588ad87910bd9d885fe27da77ad13e30', |
|
310 | + 'data/Relationships/One2OneBeanRelationship.php' => '765b8785d5ca576a8530db99bdf4d411', |
|
311 | + 'data/Relationships/One2OneRelationship.php' => '0385f7577687a402d9603ef26984257e', |
|
312 | + 'data/Relationships/RelationshipFactory.php' => '3bd7cc6998beaf82a13808f54bff1c2d', |
|
313 | + 'data/Relationships/SugarRelationship.php' => '8d0fa8ae0f41ac34eb5d0c04f0e02825', |
|
314 | + ); |
|
315 | + |
|
316 | + $actual = generateMD5array('data/Relationships/'); |
|
317 | + $this->assertSame($expected,$actual); |
|
318 | 318 | |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | |
322 | - public function testmd5DirCompare() |
|
323 | - { |
|
324 | - //execute the method and test if it returns expected values |
|
322 | + public function testmd5DirCompare() |
|
323 | + { |
|
324 | + //execute the method and test if it returns expected values |
|
325 | 325 | |
326 | - $expected= array (); |
|
326 | + $expected= array (); |
|
327 | 327 | |
328 | - $actual = md5DirCompare('include/MVC/', 'include/MVC/',array('views')); |
|
329 | - $this->assertSame($expected,$actual); |
|
328 | + $actual = md5DirCompare('include/MVC/', 'include/MVC/',array('views')); |
|
329 | + $this->assertSame($expected,$actual); |
|
330 | 330 | |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | 333 | |
334 | - public function testgetFiles() |
|
335 | - { |
|
336 | - //execute the method and test if it returns expected values |
|
334 | + public function testgetFiles() |
|
335 | + { |
|
336 | + //execute the method and test if it returns expected values |
|
337 | 337 | |
338 | - //test without pattern |
|
339 | - $expected = array ( |
|
338 | + //test without pattern |
|
339 | + $expected = array ( |
|
340 | 340 | 'include/MVC/Controller/ControllerFactory.php', |
341 | 341 | 'include/MVC/Controller/file_access_control_map.php', |
342 | 342 | 'include/MVC/Controller/action_file_map.php', |
343 | 343 | 'include/MVC/Controller/action_view_map.php', |
344 | 344 | 'include/MVC/Controller/entry_point_registry.php', |
345 | 345 | 'include/MVC/Controller/SugarController.php', |
346 | - ); |
|
347 | - $actual = Array(); |
|
348 | - getFiles($actual, 'include/MVC/Controller'); |
|
346 | + ); |
|
347 | + $actual = Array(); |
|
348 | + getFiles($actual, 'include/MVC/Controller'); |
|
349 | 349 | sort($actual); |
350 | 350 | sort($expected); |
351 | - $this->assertSame($expected,$actual); |
|
352 | - |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - //test with pattern |
|
357 | - $expected = array ( |
|
358 | - 'include/MVC/Controller/action_view_map.php', |
|
359 | - 'include/MVC/View/views/view.ajax.php', |
|
360 | - 'include/MVC/View/views/view.ajaxui.php', |
|
361 | - 'include/MVC/View/views/view.classic.config.php', |
|
362 | - 'include/MVC/View/views/view.classic.php', |
|
363 | - 'include/MVC/View/views/view.config.php', |
|
364 | - 'include/MVC/View/views/view.detail.config.php', |
|
365 | - 'include/MVC/View/views/view.detail.php', |
|
366 | - 'include/MVC/View/views/view.edit.php', |
|
367 | - 'include/MVC/View/views/view.favorites.php', |
|
368 | - 'include/MVC/View/views/view.html.php', |
|
369 | - 'include/MVC/View/views/view.importvcard.php', |
|
370 | - 'include/MVC/View/views/view.importvcardsave.php', |
|
371 | - 'include/MVC/View/views/view.json.php', |
|
372 | - 'include/MVC/View/views/view.list.php', |
|
373 | - 'include/MVC/View/views/view.metadata.php', |
|
374 | - 'include/MVC/View/views/view.modulelistmenu.php', |
|
375 | - 'include/MVC/View/views/view.multiedit.php', |
|
376 | - 'include/MVC/View/views/view.noaccess.php', |
|
377 | - 'include/MVC/View/views/view.popup.php', |
|
378 | - 'include/MVC/View/views/view.quick.php', |
|
379 | - 'include/MVC/View/views/view.quickcreate.php', |
|
380 | - 'include/MVC/View/views/view.quickedit.php', |
|
381 | - 'include/MVC/View/views/view.serialized.php', |
|
382 | - 'include/MVC/View/views/view.sugarpdf.config.php', |
|
383 | - 'include/MVC/View/views/view.sugarpdf.php', |
|
384 | - 'include/MVC/View/views/view.vcard.php', |
|
385 | - 'include/MVC/View/views/view.xml.php', |
|
386 | - ); |
|
387 | - $actual = Array(); |
|
388 | - getFiles($actual, 'include/MVC','@view@'); |
|
351 | + $this->assertSame($expected,$actual); |
|
352 | + |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + //test with pattern |
|
357 | + $expected = array ( |
|
358 | + 'include/MVC/Controller/action_view_map.php', |
|
359 | + 'include/MVC/View/views/view.ajax.php', |
|
360 | + 'include/MVC/View/views/view.ajaxui.php', |
|
361 | + 'include/MVC/View/views/view.classic.config.php', |
|
362 | + 'include/MVC/View/views/view.classic.php', |
|
363 | + 'include/MVC/View/views/view.config.php', |
|
364 | + 'include/MVC/View/views/view.detail.config.php', |
|
365 | + 'include/MVC/View/views/view.detail.php', |
|
366 | + 'include/MVC/View/views/view.edit.php', |
|
367 | + 'include/MVC/View/views/view.favorites.php', |
|
368 | + 'include/MVC/View/views/view.html.php', |
|
369 | + 'include/MVC/View/views/view.importvcard.php', |
|
370 | + 'include/MVC/View/views/view.importvcardsave.php', |
|
371 | + 'include/MVC/View/views/view.json.php', |
|
372 | + 'include/MVC/View/views/view.list.php', |
|
373 | + 'include/MVC/View/views/view.metadata.php', |
|
374 | + 'include/MVC/View/views/view.modulelistmenu.php', |
|
375 | + 'include/MVC/View/views/view.multiedit.php', |
|
376 | + 'include/MVC/View/views/view.noaccess.php', |
|
377 | + 'include/MVC/View/views/view.popup.php', |
|
378 | + 'include/MVC/View/views/view.quick.php', |
|
379 | + 'include/MVC/View/views/view.quickcreate.php', |
|
380 | + 'include/MVC/View/views/view.quickedit.php', |
|
381 | + 'include/MVC/View/views/view.serialized.php', |
|
382 | + 'include/MVC/View/views/view.sugarpdf.config.php', |
|
383 | + 'include/MVC/View/views/view.sugarpdf.php', |
|
384 | + 'include/MVC/View/views/view.vcard.php', |
|
385 | + 'include/MVC/View/views/view.xml.php', |
|
386 | + ); |
|
387 | + $actual = Array(); |
|
388 | + getFiles($actual, 'include/MVC','@view@'); |
|
389 | 389 | sort($expected); |
390 | 390 | sort($actual); |
391 | - $this->assertEquals($expected,$actual); |
|
391 | + $this->assertEquals($expected,$actual); |
|
392 | 392 | |
393 | - } |
|
393 | + } |
|
394 | 394 | |
395 | 395 | |
396 | - public function testreadfile_chunked() |
|
397 | - { |
|
398 | - //execute the method and test if it returns expected values |
|
396 | + public function testreadfile_chunked() |
|
397 | + { |
|
398 | + //execute the method and test if it returns expected values |
|
399 | 399 | |
400 | - $expected = file_get_contents('config.php'); |
|
400 | + $expected = file_get_contents('config.php'); |
|
401 | 401 | |
402 | 402 | |
403 | - //retbytes parameter false |
|
404 | - ob_start(); |
|
405 | - $actual = readfile_chunked('config.php',false); |
|
406 | - $renderedContent = ob_get_contents(); |
|
407 | - ob_end_clean(); |
|
403 | + //retbytes parameter false |
|
404 | + ob_start(); |
|
405 | + $actual = readfile_chunked('config.php',false); |
|
406 | + $renderedContent = ob_get_contents(); |
|
407 | + ob_end_clean(); |
|
408 | 408 | |
409 | - $this->assertTrue($actual); |
|
410 | - $this->assertSame($expected,$renderedContent); |
|
409 | + $this->assertTrue($actual); |
|
410 | + $this->assertSame($expected,$renderedContent); |
|
411 | 411 | |
412 | 412 | |
413 | 413 | |
414 | - //retbytes parameter true/default |
|
415 | - ob_start(); |
|
416 | - $actual = readfile_chunked('config.php'); |
|
417 | - $renderedContent = ob_get_contents(); |
|
418 | - ob_end_clean(); |
|
414 | + //retbytes parameter true/default |
|
415 | + ob_start(); |
|
416 | + $actual = readfile_chunked('config.php'); |
|
417 | + $renderedContent = ob_get_contents(); |
|
418 | + ob_end_clean(); |
|
419 | 419 | |
420 | - $this->assertEquals($actual,strlen($renderedContent)); |
|
421 | - $this->assertSame($expected,$renderedContent); |
|
420 | + $this->assertEquals($actual,strlen($renderedContent)); |
|
421 | + $this->assertSame($expected,$renderedContent); |
|
422 | 422 | |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | - public function testsugar_rename( ) |
|
426 | - { |
|
427 | - //execute the method and test if it returns true/success |
|
425 | + public function testsugar_rename( ) |
|
426 | + { |
|
427 | + //execute the method and test if it returns true/success |
|
428 | 428 | |
429 | - $dir = 'vfs://root'; |
|
430 | - $file = "test.txt"; |
|
431 | - $vfs = $this->rootFs; |
|
432 | - if ( $vfs->hasChild($file) != true) |
|
433 | - write_array_to_file('', '', $dir . '/' . $file); |
|
429 | + $dir = 'vfs://root'; |
|
430 | + $file = "test.txt"; |
|
431 | + $vfs = $this->rootFs; |
|
432 | + if ( $vfs->hasChild($file) != true) |
|
433 | + write_array_to_file('', '', $dir . '/' . $file); |
|
434 | 434 | |
435 | - //test with empty file names |
|
436 | - $actual = sugar_rename('',''); |
|
437 | - $this->assertFalse($actual); |
|
435 | + //test with empty file names |
|
436 | + $actual = sugar_rename('',''); |
|
437 | + $this->assertFalse($actual); |
|
438 | 438 | |
439 | 439 | |
440 | - //test with valid file names |
|
441 | - $actual = sugar_rename($dir . '/' . $file, $dir . '/' . 'newtest.txt'); |
|
442 | - $this->assertTrue($actual); |
|
440 | + //test with valid file names |
|
441 | + $actual = sugar_rename($dir . '/' . $file, $dir . '/' . 'newtest.txt'); |
|
442 | + $this->assertTrue($actual); |
|
443 | 443 | |
444 | - unlink($dir . '/' . 'newtest.txt'); |
|
444 | + unlink($dir . '/' . 'newtest.txt'); |
|
445 | 445 | |
446 | - } |
|
446 | + } |
|
447 | 447 | |
448 | - public function testfileToHash() |
|
449 | - { |
|
450 | - //execute the method and test if it returns expected values |
|
451 | - |
|
452 | - //test with empty filename string |
|
453 | - $expected = "d41d8cd98f00b204e9800998ecf8427e"; |
|
454 | - $hash = fileToHash(""); |
|
455 | - $this->assertSame($expected,$hash); |
|
456 | - $this->assertSame("",$_SESSION['file2Hash'][$hash]); |
|
457 | - |
|
458 | - //test with valid filename |
|
459 | - $expected = "9e5e2527d69c009a81b8ecd730f3957e"; |
|
460 | - $hash = fileToHash('config.php'); |
|
461 | - $this->assertSame($expected,$hash); |
|
462 | - $this->assertSame('config.php', $_SESSION['file2Hash'][$hash]); |
|
463 | - |
|
464 | - } |
|
448 | + public function testfileToHash() |
|
449 | + { |
|
450 | + //execute the method and test if it returns expected values |
|
451 | + |
|
452 | + //test with empty filename string |
|
453 | + $expected = "d41d8cd98f00b204e9800998ecf8427e"; |
|
454 | + $hash = fileToHash(""); |
|
455 | + $this->assertSame($expected,$hash); |
|
456 | + $this->assertSame("",$_SESSION['file2Hash'][$hash]); |
|
457 | + |
|
458 | + //test with valid filename |
|
459 | + $expected = "9e5e2527d69c009a81b8ecd730f3957e"; |
|
460 | + $hash = fileToHash('config.php'); |
|
461 | + $this->assertSame($expected,$hash); |
|
462 | + $this->assertSame('config.php', $_SESSION['file2Hash'][$hash]); |
|
463 | + |
|
464 | + } |
|
465 | 465 | |
466 | - public function testhashToFile() |
|
467 | - { |
|
468 | - //execute the method and test if it returns expected values |
|
469 | - |
|
470 | - //test with invalid hash. |
|
471 | - $actual = hashToFile(""); |
|
472 | - $this->assertFalse($actual); |
|
473 | - |
|
474 | - //test with a newly generated hash |
|
475 | - $hash = fileToHash('config.php'); |
|
476 | - $actual = hashToFile($hash); |
|
477 | - $this->assertSame('config.php', $actual); |
|
478 | - } |
|
466 | + public function testhashToFile() |
|
467 | + { |
|
468 | + //execute the method and test if it returns expected values |
|
469 | + |
|
470 | + //test with invalid hash. |
|
471 | + $actual = hashToFile(""); |
|
472 | + $this->assertFalse($actual); |
|
473 | + |
|
474 | + //test with a newly generated hash |
|
475 | + $hash = fileToHash('config.php'); |
|
476 | + $actual = hashToFile($hash); |
|
477 | + $this->assertSame('config.php', $actual); |
|
478 | + } |
|
479 | 479 | |
480 | 480 | |
481 | - public function testget_file_extension() |
|
482 | - { |
|
483 | - //execute the method and test if it returns expected values |
|
481 | + public function testget_file_extension() |
|
482 | + { |
|
483 | + //execute the method and test if it returns expected values |
|
484 | 484 | |
485 | - $this->assertSame('', get_file_extension('')); |
|
486 | - $this->assertSame('txt', get_file_extension('test.txt')); |
|
487 | - $this->assertSame('Txt', get_file_extension('test.ext.Txt',false)); |
|
488 | - $this->assertSame('txt', get_file_extension('test.ext.TXT',true)); |
|
485 | + $this->assertSame('', get_file_extension('')); |
|
486 | + $this->assertSame('txt', get_file_extension('test.txt')); |
|
487 | + $this->assertSame('Txt', get_file_extension('test.ext.Txt',false)); |
|
488 | + $this->assertSame('txt', get_file_extension('test.ext.TXT',true)); |
|
489 | 489 | |
490 | - } |
|
490 | + } |
|
491 | 491 | |
492 | 492 | |
493 | - public function testget_mime_content_type_from_filename() |
|
494 | - { |
|
495 | - //execute the method and test if it returns expected values |
|
493 | + public function testget_mime_content_type_from_filename() |
|
494 | + { |
|
495 | + //execute the method and test if it returns expected values |
|
496 | 496 | |
497 | - $this->assertSame('', get_mime_content_type_from_filename('') ); |
|
498 | - $this->assertSame('application/octet-stream', get_mime_content_type_from_filename('file.tmp') ); |
|
499 | - $this->assertSame('text/plain', get_mime_content_type_from_filename('file.txt') ); |
|
500 | - $this->assertSame('application/x-shockwave-flash', get_mime_content_type_from_filename('file.swf') ); |
|
501 | - $this->assertSame('video/x-flv', get_mime_content_type_from_filename('file.flv') ); |
|
497 | + $this->assertSame('', get_mime_content_type_from_filename('') ); |
|
498 | + $this->assertSame('application/octet-stream', get_mime_content_type_from_filename('file.tmp') ); |
|
499 | + $this->assertSame('text/plain', get_mime_content_type_from_filename('file.txt') ); |
|
500 | + $this->assertSame('application/x-shockwave-flash', get_mime_content_type_from_filename('file.swf') ); |
|
501 | + $this->assertSame('video/x-flv', get_mime_content_type_from_filename('file.flv') ); |
|
502 | 502 | |
503 | - } |
|
503 | + } |
|
504 | 504 | |
505 | - public function testcleanFileName() |
|
506 | - { |
|
507 | - //execute the method and test if it returns expected values |
|
508 | - |
|
509 | - $this->assertSame("file.txt", cleanFileName("file<?>.txt") ); |
|
510 | - $this->assertSame("file_1.txt", cleanFileName("file_1<?>.txt") ); |
|
511 | - $this->assertSame("file.txt", cleanFileName("file.txt") ); |
|
512 | - } |
|
505 | + public function testcleanFileName() |
|
506 | + { |
|
507 | + //execute the method and test if it returns expected values |
|
508 | + |
|
509 | + $this->assertSame("file.txt", cleanFileName("file<?>.txt") ); |
|
510 | + $this->assertSame("file_1.txt", cleanFileName("file_1<?>.txt") ); |
|
511 | + $this->assertSame("file.txt", cleanFileName("file.txt") ); |
|
512 | + } |
|
513 | 513 | |
514 | - public function testcleanDirName() |
|
515 | - { |
|
516 | - //execute the method and test if it returns expected values |
|
514 | + public function testcleanDirName() |
|
515 | + { |
|
516 | + //execute the method and test if it returns expected values |
|
517 | 517 | |
518 | - $this->assertSame("testDir", cleanDirName("./testDir") ); |
|
519 | - $this->assertSame("testDir", cleanDirName("..\\testDir") ); |
|
520 | - $this->assertSame("testDir", cleanDirName("\\test/Dir/") ); |
|
518 | + $this->assertSame("testDir", cleanDirName("./testDir") ); |
|
519 | + $this->assertSame("testDir", cleanDirName("..\\testDir") ); |
|
520 | + $this->assertSame("testDir", cleanDirName("\\test/Dir/") ); |
|
521 | 521 | |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | 524 | } |
525 | 525 | \ No newline at end of file |
@@ -10,159 +10,159 @@ |
||
10 | 10 | $rootFs->addChild(org\bovigo\vfs\vfsStream::newFile('test.txt')->withContent("Hello world!")); |
11 | 11 | } |
12 | 12 | |
13 | - public function testsugar_mkdir() |
|
14 | - { |
|
15 | - //execute the method and test if it returns true and created dir exists |
|
13 | + public function testsugar_mkdir() |
|
14 | + { |
|
15 | + //execute the method and test if it returns true and created dir exists |
|
16 | 16 | |
17 | - $dir = "vfs://root"; |
|
17 | + $dir = "vfs://root"; |
|
18 | 18 | |
19 | - //non recursive |
|
20 | - $result = sugar_mkdir($dir . "/mkdirTest"); |
|
21 | - $this->assertFileExists($dir . "/mkdirTest"); |
|
22 | - $this->assertTrue($result); |
|
19 | + //non recursive |
|
20 | + $result = sugar_mkdir($dir . "/mkdirTest"); |
|
21 | + $this->assertFileExists($dir . "/mkdirTest"); |
|
22 | + $this->assertTrue($result); |
|
23 | 23 | |
24 | - //recursive |
|
25 | - $result = sugar_mkdir($dir . "/mkdirTest/test",null,true); |
|
26 | - $this->assertFileExists($dir . "/mkdirTest/test"); |
|
27 | - $this->assertTrue($result); |
|
28 | - } |
|
24 | + //recursive |
|
25 | + $result = sugar_mkdir($dir . "/mkdirTest/test",null,true); |
|
26 | + $this->assertFileExists($dir . "/mkdirTest/test"); |
|
27 | + $this->assertTrue($result); |
|
28 | + } |
|
29 | 29 | |
30 | - public function testsugar_fopen() |
|
31 | - { |
|
32 | - //execute the method and test if it doesn't returns false |
|
33 | - $result = sugar_fopen('vfs://root/test.txt', 'r'); |
|
34 | - $this->assertNotFalse($result); |
|
35 | - } |
|
30 | + public function testsugar_fopen() |
|
31 | + { |
|
32 | + //execute the method and test if it doesn't returns false |
|
33 | + $result = sugar_fopen('vfs://root/test.txt', 'r'); |
|
34 | + $this->assertNotFalse($result); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - public function testsugar_file_put_contents() |
|
39 | - { |
|
40 | - //execute the method and test if it doesn't returns false and returns the number of bytes written |
|
38 | + public function testsugar_file_put_contents() |
|
39 | + { |
|
40 | + //execute the method and test if it doesn't returns false and returns the number of bytes written |
|
41 | 41 | |
42 | 42 | $dir = "vfs://root"; |
43 | - $result = sugar_file_put_contents( $dir . '/testfile.txt', 'some test data'); |
|
44 | - $this->assertNotFalse($result); |
|
45 | - $this->assertEquals(14,$result); |
|
46 | - } |
|
43 | + $result = sugar_file_put_contents( $dir . '/testfile.txt', 'some test data'); |
|
44 | + $this->assertNotFalse($result); |
|
45 | + $this->assertEquals(14,$result); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - public function testsugar_file_put_contents_atomic() |
|
51 | - { |
|
50 | + public function testsugar_file_put_contents_atomic() |
|
51 | + { |
|
52 | 52 | $this->markTestSkipped('Atomic file put cannot be tested with vfsStream'); |
53 | - //execute the method and test if it returns success(true) |
|
53 | + //execute the method and test if it returns success(true) |
|
54 | 54 | $dir = "vfs://root"; |
55 | - $result = sugar_file_put_contents_atomic( $dir . '/atomictestfile.txt', 'some test data'); |
|
56 | - $this->assertTrue($result); |
|
57 | - } |
|
55 | + $result = sugar_file_put_contents_atomic( $dir . '/atomictestfile.txt', 'some test data'); |
|
56 | + $this->assertTrue($result); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - public function testsugar_file_get_contents() |
|
61 | - { |
|
62 | - //execute the method and test if it doesn't returns false and returns the expected contents |
|
60 | + public function testsugar_file_get_contents() |
|
61 | + { |
|
62 | + //execute the method and test if it doesn't returns false and returns the expected contents |
|
63 | 63 | $dir = "vfs://root"; |
64 | - $result = file_get_contents( $dir . '/test.txt'); |
|
64 | + $result = file_get_contents( $dir . '/test.txt'); |
|
65 | 65 | |
66 | - $this->assertNotFalse($result); |
|
67 | - $this->assertEquals('Hello world!',$result); |
|
68 | - } |
|
66 | + $this->assertNotFalse($result); |
|
67 | + $this->assertEquals('Hello world!',$result); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - public function testsugar_touch() |
|
72 | - { |
|
73 | - //execute the method and test if it returns success(true) |
|
71 | + public function testsugar_touch() |
|
72 | + { |
|
73 | + //execute the method and test if it returns success(true) |
|
74 | 74 | |
75 | 75 | $dir = "vfs://root"; |
76 | - $test_dt = time() - 3600 ; |
|
77 | - $expected = date("m d Y H:i:s", time() - 3600 ); |
|
76 | + $test_dt = time() - 3600 ; |
|
77 | + $expected = date("m d Y H:i:s", time() - 3600 ); |
|
78 | 78 | |
79 | - //test wihout modified date param |
|
80 | - $result = sugar_touch( $dir . '/testfiletouch.txt'); |
|
81 | - $this->assertTrue($result); |
|
79 | + //test wihout modified date param |
|
80 | + $result = sugar_touch( $dir . '/testfiletouch.txt'); |
|
81 | + $this->assertTrue($result); |
|
82 | 82 | |
83 | - //test wih modified date param |
|
84 | - $result = sugar_touch( $dir . '/testfiletouch.txt',$test_dt,$test_dt); |
|
85 | - $file_dt = date ("m d Y H:i:s", filemtime($dir . '/testfiletouch.txt')) ; |
|
83 | + //test wih modified date param |
|
84 | + $result = sugar_touch( $dir . '/testfiletouch.txt',$test_dt,$test_dt); |
|
85 | + $file_dt = date ("m d Y H:i:s", filemtime($dir . '/testfiletouch.txt')) ; |
|
86 | 86 | |
87 | - $this->assertTrue($result); |
|
88 | - $this->assertSame($file_dt, $expected ); |
|
89 | - } |
|
87 | + $this->assertTrue($result); |
|
88 | + $this->assertSame($file_dt, $expected ); |
|
89 | + } |
|
90 | 90 | |
91 | 91 | |
92 | - public function testsugar_chmod() |
|
93 | - { |
|
92 | + public function testsugar_chmod() |
|
93 | + { |
|
94 | 94 | $this->markTestSkipped('Permissions cannot be tested with vfsStream'); |
95 | - //execute the method and test if it returns success(true) |
|
95 | + //execute the method and test if it returns success(true) |
|
96 | 96 | $dir = "vfs://test"; |
97 | - $result = sugar_chmod($dir . '/test.txt',0777); |
|
98 | - $this->assertTrue($result); |
|
99 | - } |
|
97 | + $result = sugar_chmod($dir . '/test.txt',0777); |
|
98 | + $this->assertTrue($result); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | - public function testsugar_chown() |
|
103 | - { |
|
102 | + public function testsugar_chown() |
|
103 | + { |
|
104 | 104 | $this->markTestSkipped('Permissions cannot be tested with vfsStream'); |
105 | - //execute the method and test if it returns success(true) |
|
105 | + //execute the method and test if it returns success(true) |
|
106 | 106 | $dir = "vfs://test"; |
107 | - $result = sugar_chown($dir . '/test.txt'); |
|
108 | - $this->assertFalse($result); |
|
107 | + $result = sugar_chown($dir . '/test.txt'); |
|
108 | + $this->assertFalse($result); |
|
109 | 109 | |
110 | 110 | $result = sugar_chown($dir . '/test.txt',org\bovigo\vfs\vfsStream::getCurrentUser()); |
111 | 111 | $this->assertTrue($result); |
112 | 112 | |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - public function testsugar_chgrp() |
|
117 | - { |
|
116 | + public function testsugar_chgrp() |
|
117 | + { |
|
118 | 118 | $this->markTestSkipped('Permissions cannot be tested with vfsStream'); |
119 | - //execute the method and test if it returns success(true) |
|
119 | + //execute the method and test if it returns success(true) |
|
120 | 120 | $dir = "vfs://test"; |
121 | - $result = sugar_chgrp($dir . '/test.txt'); |
|
122 | - $this->assertFalse($result); |
|
121 | + $result = sugar_chgrp($dir . '/test.txt'); |
|
122 | + $this->assertFalse($result); |
|
123 | 123 | |
124 | 124 | $result = sugar_chgrp($dir . '/test.txt',org\bovigo\vfs\vfsStream::getCurrentGroup()); |
125 | 125 | $this->assertFalse($result); |
126 | - } |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | - public function testget_mode() |
|
130 | - { |
|
131 | - //test with all mods defined in config |
|
132 | - $this->assertSame(1528,get_mode()); |
|
133 | - $this->assertSame(1528,get_mode('dir_mode', 10)); |
|
134 | - $this->assertSame(493,get_mode('file_mode', 10)); |
|
135 | - $this->assertSame('',get_mode('user', 10)); |
|
136 | - $this->assertSame('',get_mode('group', 10)); |
|
137 | - } |
|
138 | - |
|
139 | - public function testsugar_is_dir() |
|
140 | - { |
|
141 | - $dir = "vfs://root"; |
|
129 | + public function testget_mode() |
|
130 | + { |
|
131 | + //test with all mods defined in config |
|
132 | + $this->assertSame(1528,get_mode()); |
|
133 | + $this->assertSame(1528,get_mode('dir_mode', 10)); |
|
134 | + $this->assertSame(493,get_mode('file_mode', 10)); |
|
135 | + $this->assertSame('',get_mode('user', 10)); |
|
136 | + $this->assertSame('',get_mode('group', 10)); |
|
137 | + } |
|
138 | + |
|
139 | + public function testsugar_is_dir() |
|
140 | + { |
|
141 | + $dir = "vfs://root"; |
|
142 | 142 | |
143 | - $this->assertFalse(sugar_is_dir('')); //invalid dir |
|
143 | + $this->assertFalse(sugar_is_dir('')); //invalid dir |
|
144 | 144 | $this->assertFalse(sugar_is_dir($dir."/foo")); //invalid dir |
145 | - $this->assertTrue(sugar_is_dir($dir."/testDir")); //valid dir |
|
145 | + $this->assertTrue(sugar_is_dir($dir."/testDir")); //valid dir |
|
146 | 146 | |
147 | - } |
|
148 | - |
|
149 | - public function testsugar_is_file() |
|
150 | - { |
|
151 | - $this->assertFalse(sugar_is_file('')); //invalid file |
|
152 | - $this->assertFalse(sugar_is_file('vfs://config')); //invalid file |
|
153 | - $this->assertTrue(is_file('vfs://root/test.txt')); //valid file |
|
154 | - } |
|
147 | + } |
|
148 | + |
|
149 | + public function testsugar_is_file() |
|
150 | + { |
|
151 | + $this->assertFalse(sugar_is_file('')); //invalid file |
|
152 | + $this->assertFalse(sugar_is_file('vfs://config')); //invalid file |
|
153 | + $this->assertTrue(is_file('vfs://root/test.txt')); //valid file |
|
154 | + } |
|
155 | 155 | |
156 | 156 | |
157 | - public function testsugar_cached() |
|
158 | - { |
|
159 | - $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
|
157 | + public function testsugar_cached() |
|
158 | + { |
|
159 | + $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\'); |
|
160 | 160 | |
161 | - $this->assertSame($cache_dir . '/', sugar_cached('')); //invalid file |
|
162 | - $this->assertSame($cache_dir . '/config', sugar_cached('config')); //valid file |
|
163 | - $this->assertSame($cache_dir . '/modules' , sugar_cached('modules')); //valid file |
|
161 | + $this->assertSame($cache_dir . '/', sugar_cached('')); //invalid file |
|
162 | + $this->assertSame($cache_dir . '/config', sugar_cached('config')); //valid file |
|
163 | + $this->assertSame($cache_dir . '/modules' , sugar_cached('modules')); //valid file |
|
164 | 164 | |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | 167 | |
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -8,26 +8,26 @@ discard block |
||
8 | 8 | class logic_utilsTest extends PHPUnit_Framework_TestCase |
9 | 9 | { |
10 | 10 | |
11 | - public function testget_hook_array() |
|
12 | - { |
|
13 | - //test with a vaid module. it will return an array |
|
14 | - $AccountsHooks = get_hook_array('Accounts'); |
|
15 | - $this->assertTrue(is_array($AccountsHooks)); |
|
11 | + public function testget_hook_array() |
|
12 | + { |
|
13 | + //test with a vaid module. it will return an array |
|
14 | + $AccountsHooks = get_hook_array('Accounts'); |
|
15 | + $this->assertTrue(is_array($AccountsHooks)); |
|
16 | 16 | |
17 | - //test with an invalid array. it will throw an file include exception. |
|
18 | - $BugsHooks = ""; |
|
19 | - try{ |
|
20 | - $BugsHooks = get_hook_array('Bugs'); |
|
21 | - }catch(Exception $e){} |
|
17 | + //test with an invalid array. it will throw an file include exception. |
|
18 | + $BugsHooks = ""; |
|
19 | + try{ |
|
20 | + $BugsHooks = get_hook_array('Bugs'); |
|
21 | + }catch(Exception $e){} |
|
22 | 22 | |
23 | - $this->assertFalse(is_array($BugsHooks)); |
|
23 | + $this->assertFalse(is_array($BugsHooks)); |
|
24 | 24 | |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - private function getTestHook(){ |
|
28 | + private function getTestHook(){ |
|
29 | 29 | |
30 | - //array containing hooks array to test |
|
30 | + //array containing hooks array to test |
|
31 | 31 | |
32 | 32 | $hook_array = Array(); |
33 | 33 | $hook_array['after_ui_footer'] = Array(); |
@@ -43,80 +43,80 @@ discard block |
||
43 | 43 | $hook_array['after_restore'] = array(); |
44 | 44 | $hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); |
45 | 45 | |
46 | - return $hook_array; |
|
47 | - } |
|
46 | + return $hook_array; |
|
47 | + } |
|
48 | 48 | |
49 | - public function check_existing_elementProvider() |
|
50 | - { |
|
51 | - //provide test cases dataset to validate |
|
52 | - |
|
53 | - $hook_array = $this->getTestHook(); |
|
54 | - return array( |
|
55 | - array($hook_array,'after_save',array(0,'popup_select'), true), |
|
56 | - array($hook_array,'after_save',array(0,'foo'), false), |
|
57 | - array($hook_array,'foo',array(0,'popup_select'), false), |
|
58 | - ); |
|
59 | - } |
|
49 | + public function check_existing_elementProvider() |
|
50 | + { |
|
51 | + //provide test cases dataset to validate |
|
52 | + |
|
53 | + $hook_array = $this->getTestHook(); |
|
54 | + return array( |
|
55 | + array($hook_array,'after_save',array(0,'popup_select'), true), |
|
56 | + array($hook_array,'after_save',array(0,'foo'), false), |
|
57 | + array($hook_array,'foo',array(0,'popup_select'), false), |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @dataProvider check_existing_elementProvider |
|
63 | - */ |
|
64 | - public function testcheck_existing_element($hook_array, $event, $action_array, $expected) |
|
65 | - { |
|
66 | - //test with dataset containing valid and invalid cases |
|
67 | - $this->assertSame( check_existing_element($hook_array,$event, $action_array) , $expected); |
|
68 | - |
|
69 | - } |
|
61 | + /** |
|
62 | + * @dataProvider check_existing_elementProvider |
|
63 | + */ |
|
64 | + public function testcheck_existing_element($hook_array, $event, $action_array, $expected) |
|
65 | + { |
|
66 | + //test with dataset containing valid and invalid cases |
|
67 | + $this->assertSame( check_existing_element($hook_array,$event, $action_array) , $expected); |
|
68 | + |
|
69 | + } |
|
70 | 70 | |
71 | - public function testreplace_or_add_logic_type() |
|
72 | - { |
|
73 | - //execute the method and test if it returns expected values |
|
71 | + public function testreplace_or_add_logic_type() |
|
72 | + { |
|
73 | + //execute the method and test if it returns expected values |
|
74 | 74 | |
75 | - $hook_array = $this->getTestHook(); |
|
76 | - $expected = "<?php\n// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n\n?>"; |
|
77 | - $this->assertEquals($expected,replace_or_add_logic_type($hook_array)); |
|
75 | + $hook_array = $this->getTestHook(); |
|
76 | + $expected = "<?php\n// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n\n?>"; |
|
77 | + $this->assertEquals($expected,replace_or_add_logic_type($hook_array)); |
|
78 | 78 | |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - public function testwrite_logic_file() |
|
82 | - { |
|
83 | - //execute the method and test if it returns expected values, |
|
84 | - //check if file is created and contains expected contents |
|
81 | + public function testwrite_logic_file() |
|
82 | + { |
|
83 | + //execute the method and test if it returns expected values, |
|
84 | + //check if file is created and contains expected contents |
|
85 | 85 | |
86 | - $vfs = vfsStream::setup('custom/modules/TEST_Test'); |
|
86 | + $vfs = vfsStream::setup('custom/modules/TEST_Test'); |
|
87 | 87 | |
88 | - if ( $vfs->hasChild('logic_hooks.php') == true) { |
|
89 | - unlink('custom/modules/TEST_Test/logic_hooks.php'); |
|
90 | - rmdir('custom/modules/TEST_Test'); |
|
91 | - } |
|
88 | + if ( $vfs->hasChild('logic_hooks.php') == true) { |
|
89 | + unlink('custom/modules/TEST_Test/logic_hooks.php'); |
|
90 | + rmdir('custom/modules/TEST_Test'); |
|
91 | + } |
|
92 | 92 | |
93 | - $expectedContents = "<?php\n// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n\n?>"; |
|
94 | - write_logic_file('TEST_Test',$expectedContents); |
|
93 | + $expectedContents = "<?php\n// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n\n?>"; |
|
94 | + write_logic_file('TEST_Test',$expectedContents); |
|
95 | 95 | |
96 | - //Check file created |
|
97 | - $this->assertFileExists('custom/modules/TEST_Test/logic_hooks.php'); |
|
98 | - $actualContents = file_get_contents('custom/modules/TEST_Test/logic_hooks.php'); |
|
99 | - $this->assertSame($expectedContents, $actualContents); |
|
96 | + //Check file created |
|
97 | + $this->assertFileExists('custom/modules/TEST_Test/logic_hooks.php'); |
|
98 | + $actualContents = file_get_contents('custom/modules/TEST_Test/logic_hooks.php'); |
|
99 | + $this->assertSame($expectedContents, $actualContents); |
|
100 | 100 | |
101 | - $expectedArray = $this->getTestHook(); |
|
101 | + $expectedArray = $this->getTestHook(); |
|
102 | 102 | |
103 | - $actualArray = get_hook_array('TEST_Test'); |
|
103 | + $actualArray = get_hook_array('TEST_Test'); |
|
104 | 104 | |
105 | - $this->assertSame($expectedArray, $actualArray); |
|
105 | + $this->assertSame($expectedArray, $actualArray); |
|
106 | 106 | |
107 | - unlink('custom/modules/TEST_Test/logic_hooks.php'); |
|
108 | - rmdir('custom/modules/TEST_Test'); |
|
107 | + unlink('custom/modules/TEST_Test/logic_hooks.php'); |
|
108 | + rmdir('custom/modules/TEST_Test'); |
|
109 | 109 | |
110 | - } |
|
110 | + } |
|
111 | 111 | |
112 | - public function testbuild_logic_file() |
|
113 | - { |
|
114 | - //execute the method and test if it returns expected values |
|
115 | - |
|
116 | - $hook_array = $this->getTestHook(); |
|
117 | - $expected = "// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n"; |
|
118 | - $this->assertEquals($expected,build_logic_file($hook_array)); |
|
119 | - } |
|
112 | + public function testbuild_logic_file() |
|
113 | + { |
|
114 | + //execute the method and test if it returns expected values |
|
115 | + |
|
116 | + $hook_array = $this->getTestHook(); |
|
117 | + $expected = "// Do not store anything in this file that is not part of the array or the hook version. This file will \n// be automatically rebuilt in the future. \n \$hook_version = 1; \n\$hook_array = Array(); \n// position, file, function \n\$hook_array['after_ui_footer'] = Array(); \n\$hook_array['after_ui_footer'][] = Array(10, 'popup_onload', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_onload'); \n\$hook_array['after_ui_frame'] = Array(); \n\$hook_array['after_ui_frame'][] = Array(20, 'mass_assign', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'mass_assign'); \n\$hook_array['after_ui_frame'][] = Array(1, 'Load Social JS', 'custom/include/social/hooks.php','hooks', 'load_js'); \n\$hook_array['after_save'] = Array(); \n\$hook_array['after_save'][] = Array(30, 'popup_select', 'modules/SecurityGroups/AssignGroups.php','AssignGroups', 'popup_select'); \n\$hook_array['after_save'][] = Array(1, 'AOD Index Changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleChanges'); \n\$hook_array['after_delete'] = Array(); \n\$hook_array['after_delete'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleDelete'); \n\$hook_array['after_restore'] = Array(); \n\$hook_array['after_restore'][] = Array(1, 'AOD Index changes', 'modules/AOD_Index/AOD_LogicHooks.php','AOD_LogicHooks', 'saveModuleRestore'); \n\n\n"; |
|
118 | + $this->assertEquals($expected,build_logic_file($hook_array)); |
|
119 | + } |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | ?> |
@@ -6,130 +6,130 @@ |
||
6 | 6 | |
7 | 7 | |
8 | 8 | |
9 | - public function db_convertProvider() |
|
10 | - { |
|
11 | - //array containing all possible types supported by db_convert |
|
12 | - return array( |
|
13 | - array(gmdate('Y-m-d H:i:s'),'today',array(),'CURDATE()'), |
|
14 | - array('text','left',array(2),'LEFT(text,2)'), |
|
15 | - array('2015-11-16 19:10:52','date_format',array(),'DATE_FORMAT(2015-11-16 19:10:52,\'%Y-%m-%d\')'), |
|
16 | - array('2015-11-16 19:10:52','time_format',array(), '2015-11-16 19:10:52' ), |
|
17 | - array('2015-11-16','date',array(), '2015-11-16' ), |
|
18 | - array('19:10:52','time',array(), '19:10:52' ), |
|
19 | - array('2015-11-16 19:10:52','datetime',array(), '2015-11-16 19:10:52'), |
|
20 | - array(Null,'ifnull',array(0), 'IFNULL(0)' ), |
|
21 | - array('value1 ','concat',array('value2'), 'CONCAT(value1 ,value2)' ), |
|
22 | - array('2015-11-16 19:10:52','quarter',array(), 'QUARTER(2015-11-16 19:10:52)' ), |
|
23 | - array('value1','length',array(), 'LENGTH(value1)' ), |
|
24 | - array('2015-11-16 19:32:29', 'month',array(), 'MONTH(2015-11-16 19:32:29)' ), |
|
25 | - array('2015-11-16','add_date',array('1','DAY'), 'DATE_ADD(2015-11-16, INTERVAL 1 DAY)' ), |
|
26 | - array('19:10:52','add_time',array('1', 'HOUR'), 'DATE_ADD(19:10:52, INTERVAL + CONCAT(1, \':\', HOUR) HOUR_MINUTE)' ), |
|
27 | - array('col','avg',array(2), 'avg(col)' ), |
|
28 | - array('2015-11-16 19:32:29','add_tz_offset',array(), '2015-11-16 19:32:29 + INTERVAL 0 MINUTE' ), |
|
9 | + public function db_convertProvider() |
|
10 | + { |
|
11 | + //array containing all possible types supported by db_convert |
|
12 | + return array( |
|
13 | + array(gmdate('Y-m-d H:i:s'),'today',array(),'CURDATE()'), |
|
14 | + array('text','left',array(2),'LEFT(text,2)'), |
|
15 | + array('2015-11-16 19:10:52','date_format',array(),'DATE_FORMAT(2015-11-16 19:10:52,\'%Y-%m-%d\')'), |
|
16 | + array('2015-11-16 19:10:52','time_format',array(), '2015-11-16 19:10:52' ), |
|
17 | + array('2015-11-16','date',array(), '2015-11-16' ), |
|
18 | + array('19:10:52','time',array(), '19:10:52' ), |
|
19 | + array('2015-11-16 19:10:52','datetime',array(), '2015-11-16 19:10:52'), |
|
20 | + array(Null,'ifnull',array(0), 'IFNULL(0)' ), |
|
21 | + array('value1 ','concat',array('value2'), 'CONCAT(value1 ,value2)' ), |
|
22 | + array('2015-11-16 19:10:52','quarter',array(), 'QUARTER(2015-11-16 19:10:52)' ), |
|
23 | + array('value1','length',array(), 'LENGTH(value1)' ), |
|
24 | + array('2015-11-16 19:32:29', 'month',array(), 'MONTH(2015-11-16 19:32:29)' ), |
|
25 | + array('2015-11-16','add_date',array('1','DAY'), 'DATE_ADD(2015-11-16, INTERVAL 1 DAY)' ), |
|
26 | + array('19:10:52','add_time',array('1', 'HOUR'), 'DATE_ADD(19:10:52, INTERVAL + CONCAT(1, \':\', HOUR) HOUR_MINUTE)' ), |
|
27 | + array('col','avg',array(2), 'avg(col)' ), |
|
28 | + array('2015-11-16 19:32:29','add_tz_offset',array(), '2015-11-16 19:32:29 + INTERVAL 0 MINUTE' ), |
|
29 | 29 | |
30 | - ); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @dataProvider db_convertProvider |
|
35 | - */ |
|
36 | - public function testdb_convert($string, $type, $params, $expected) |
|
37 | - { |
|
38 | - //execute the method and test if it returns expected values for all types |
|
39 | - $actual = db_convert($string, $type,$params); |
|
40 | - $this->assertSame($expected,$actual); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - public function testdb_concat() |
|
45 | - { |
|
46 | - error_reporting(E_ERROR | E_PARSE); |
|
30 | + ); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @dataProvider db_convertProvider |
|
35 | + */ |
|
36 | + public function testdb_convert($string, $type, $params, $expected) |
|
37 | + { |
|
38 | + //execute the method and test if it returns expected values for all types |
|
39 | + $actual = db_convert($string, $type,$params); |
|
40 | + $this->assertSame($expected,$actual); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + public function testdb_concat() |
|
45 | + { |
|
46 | + error_reporting(E_ERROR | E_PARSE); |
|
47 | 47 | |
48 | - //execute the method and test if it returns expected values |
|
48 | + //execute the method and test if it returns expected values |
|
49 | 49 | |
50 | - $table = "Table1"; |
|
51 | - $fields = Array('Col1','Col2','Col3'); |
|
52 | - $expected = "LTRIM(RTRIM(CONCAT(IFNULL(Table1.Col1,''),'',IFNULL(Table1.Col2,''),'',IFNULL(Table1.Col3,''))))"; |
|
53 | - $actual = db_concat($table, $fields); |
|
54 | - $this->assertSame($expected,$actual); |
|
55 | - } |
|
50 | + $table = "Table1"; |
|
51 | + $fields = Array('Col1','Col2','Col3'); |
|
52 | + $expected = "LTRIM(RTRIM(CONCAT(IFNULL(Table1.Col1,''),'',IFNULL(Table1.Col2,''),'',IFNULL(Table1.Col3,''))))"; |
|
53 | + $actual = db_concat($table, $fields); |
|
54 | + $this->assertSame($expected,$actual); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - public function testfrom_db_convert() |
|
59 | - { |
|
60 | - //execute the method and test if it returns expected values |
|
58 | + public function testfrom_db_convert() |
|
59 | + { |
|
60 | + //execute the method and test if it returns expected values |
|
61 | 61 | |
62 | - $this->assertSame("2015-11-16 19:32:29", from_db_convert("2015-11-16 19:32:29","date")); |
|
63 | - $this->assertSame("19:32:29",from_db_convert("19:32:29","time")); |
|
64 | - $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","datetime")); |
|
65 | - $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","datetimecombo")); |
|
66 | - $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","timestamp")); |
|
62 | + $this->assertSame("2015-11-16 19:32:29", from_db_convert("2015-11-16 19:32:29","date")); |
|
63 | + $this->assertSame("19:32:29",from_db_convert("19:32:29","time")); |
|
64 | + $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","datetime")); |
|
65 | + $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","datetimecombo")); |
|
66 | + $this->assertSame("2015-11-16 19:32:29",from_db_convert("2015-11-16 19:32:29","timestamp")); |
|
67 | 67 | |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - public function testto_html() |
|
72 | - { |
|
73 | - //execute the method and test if it returns expected values |
|
71 | + public function testto_html() |
|
72 | + { |
|
73 | + //execute the method and test if it returns expected values |
|
74 | 74 | |
75 | - $string = ""; |
|
76 | - $expected = ""; |
|
77 | - $actual = to_html($string); |
|
78 | - $this->assertSame($expected,$actual); |
|
75 | + $string = ""; |
|
76 | + $expected = ""; |
|
77 | + $actual = to_html($string); |
|
78 | + $this->assertSame($expected,$actual); |
|
79 | 79 | |
80 | - $string = "'test'&trial<\">"; |
|
81 | - $expected = "'test'&trial<">"; |
|
82 | - $actual = to_html($string); |
|
83 | - $this->assertSame($expected,$actual); |
|
80 | + $string = "'test'&trial<\">"; |
|
81 | + $expected = "'test'&trial<">"; |
|
82 | + $actual = to_html($string); |
|
83 | + $this->assertSame($expected,$actual); |
|
84 | 84 | |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
89 | - public function testfrom_html() |
|
90 | - { |
|
89 | + public function testfrom_html() |
|
90 | + { |
|
91 | 91 | |
92 | - $string = ""; |
|
93 | - $expected = ""; |
|
94 | - $actual = from_html($string); |
|
95 | - $this->assertSame($expected,$actual); |
|
92 | + $string = ""; |
|
93 | + $expected = ""; |
|
94 | + $actual = from_html($string); |
|
95 | + $this->assertSame($expected,$actual); |
|
96 | 96 | |
97 | - $string = "'test'&trial<">"; |
|
98 | - $expected = "'test'&trial<\">"; |
|
99 | - $actual = from_html($string); |
|
100 | - $this->assertSame($expected,$actual); |
|
97 | + $string = "'test'&trial<">"; |
|
98 | + $expected = "'test'&trial<\">"; |
|
99 | + $actual = from_html($string); |
|
100 | + $this->assertSame($expected,$actual); |
|
101 | 101 | |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - public function testgetValidDBName() |
|
106 | - { |
|
107 | - $expected =""; |
|
108 | - $actual = getValidDBName(""); |
|
109 | - $this->assertSame($expected,$actual); |
|
105 | + public function testgetValidDBName() |
|
106 | + { |
|
107 | + $expected =""; |
|
108 | + $actual = getValidDBName(""); |
|
109 | + $this->assertSame($expected,$actual); |
|
110 | 110 | |
111 | 111 | |
112 | - $expected = "col"; |
|
113 | - $actual = getValidDBName("Col"); |
|
114 | - $this->assertSame($expected,$actual); |
|
112 | + $expected = "col"; |
|
113 | + $actual = getValidDBName("Col"); |
|
114 | + $this->assertSame($expected,$actual); |
|
115 | 115 | |
116 | - } |
|
116 | + } |
|
117 | 117 | |
118 | 118 | |
119 | - public function testisValidDBName() |
|
120 | - { |
|
121 | - //valid value |
|
122 | - $expected = true; |
|
123 | - $actual = isValidDBName("suitecrmtest","mysql"); |
|
124 | - $this->assertSame($expected,$actual); |
|
119 | + public function testisValidDBName() |
|
120 | + { |
|
121 | + //valid value |
|
122 | + $expected = true; |
|
123 | + $actual = isValidDBName("suitecrmtest","mysql"); |
|
124 | + $this->assertSame($expected,$actual); |
|
125 | 125 | |
126 | - //invalid value |
|
127 | - $expected = false; |
|
128 | - $actual = isValidDBName("suite/crm.test","mysql"); |
|
129 | - $this->assertSame($expected,$actual); |
|
126 | + //invalid value |
|
127 | + $expected = false; |
|
128 | + $actual = isValidDBName("suite/crm.test","mysql"); |
|
129 | + $this->assertSame($expected,$actual); |
|
130 | 130 | |
131 | 131 | |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | |
135 | 135 | } |
@@ -6,113 +6,113 @@ |
||
6 | 6 | { |
7 | 7 | |
8 | 8 | |
9 | - public function testget_form_header() |
|
10 | - { |
|
11 | - error_reporting(E_ERROR | E_PARSE); |
|
9 | + public function testget_form_header() |
|
10 | + { |
|
11 | + error_reporting(E_ERROR | E_PARSE); |
|
12 | 12 | |
13 | - //execute the method and test if it returns html and contains the values provided in parameters |
|
13 | + //execute the method and test if it returns html and contains the values provided in parameters |
|
14 | 14 | |
15 | - //help param true |
|
16 | - $html1 = get_form_header("test Header", "test subheader", true); |
|
17 | - $this->assertGreaterThan(0,strlen($html1)); |
|
18 | - $this->assertNotFalse(strpos($html1,"test Header")); |
|
19 | - $this->assertNotFalse(strpos($html1,"test subheader")); |
|
15 | + //help param true |
|
16 | + $html1 = get_form_header("test Header", "test subheader", true); |
|
17 | + $this->assertGreaterThan(0,strlen($html1)); |
|
18 | + $this->assertNotFalse(strpos($html1,"test Header")); |
|
19 | + $this->assertNotFalse(strpos($html1,"test subheader")); |
|
20 | 20 | |
21 | 21 | |
22 | - // help param false |
|
23 | - $html2 = get_form_header("new test Header", "new test subheader", false); |
|
24 | - $this->assertGreaterThan(0,strlen($html2)); |
|
25 | - $this->assertNotFalse(strpos($html2,"new test Header")); |
|
26 | - $this->assertNotFalse(strpos($html2,"new test subheader")); |
|
22 | + // help param false |
|
23 | + $html2 = get_form_header("new test Header", "new test subheader", false); |
|
24 | + $this->assertGreaterThan(0,strlen($html2)); |
|
25 | + $this->assertNotFalse(strpos($html2,"new test Header")); |
|
26 | + $this->assertNotFalse(strpos($html2,"new test subheader")); |
|
27 | 27 | |
28 | 28 | |
29 | - $this->assertGreaterThan(strlen($html2),strlen($html1)); |
|
29 | + $this->assertGreaterThan(strlen($html2),strlen($html1)); |
|
30 | 30 | |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - public function testget_module_title( ) |
|
35 | - { |
|
36 | - //execute the method and test if it returns html and contains the values provided in parameters |
|
37 | - |
|
38 | - //with show_create true, generates more html |
|
39 | - $html1 = get_module_title("Users", "Users Home", true ); |
|
40 | - $this->assertGreaterThan(0,strlen($html1)); |
|
41 | - $this->assertNotFalse(strpos($html1,"Users")); |
|
42 | - $this->assertNotFalse(strpos($html1,"Users Home")); |
|
43 | - |
|
44 | - //with show_create false, generates less html |
|
45 | - $html2 = get_module_title("Users", "Users Home", false ); |
|
46 | - $this->assertGreaterThan(0,strlen($html2)); |
|
47 | - $this->assertNotFalse(strpos($html2,"Users")); |
|
48 | - $this->assertNotFalse(strpos($html2,"Users Home")); |
|
49 | - $this->assertGreaterThan(strlen($html2),strlen($html1)); |
|
34 | + public function testget_module_title( ) |
|
35 | + { |
|
36 | + //execute the method and test if it returns html and contains the values provided in parameters |
|
37 | + |
|
38 | + //with show_create true, generates more html |
|
39 | + $html1 = get_module_title("Users", "Users Home", true ); |
|
40 | + $this->assertGreaterThan(0,strlen($html1)); |
|
41 | + $this->assertNotFalse(strpos($html1,"Users")); |
|
42 | + $this->assertNotFalse(strpos($html1,"Users Home")); |
|
43 | + |
|
44 | + //with show_create false, generates less html |
|
45 | + $html2 = get_module_title("Users", "Users Home", false ); |
|
46 | + $this->assertGreaterThan(0,strlen($html2)); |
|
47 | + $this->assertNotFalse(strpos($html2,"Users")); |
|
48 | + $this->assertNotFalse(strpos($html2,"Users Home")); |
|
49 | + $this->assertGreaterThan(strlen($html2),strlen($html1)); |
|
50 | 50 | |
51 | - //with show_create flase and count > 1, generates more html compared to count =0 |
|
52 | - $html3 = get_module_title("Users", "Users Home", false, 2 ); |
|
53 | - $this->assertGreaterThan(0,strlen($html3)); |
|
54 | - $this->assertNotFalse(strpos($html3,"Users")); |
|
55 | - $this->assertNotFalse(strpos($html3,"Users Home")); |
|
56 | - $this->assertGreaterThan(strlen($html2),strlen($html3)); |
|
57 | - $this->assertGreaterThan(strlen($html3),strlen($html1)); |
|
58 | - |
|
59 | - } |
|
51 | + //with show_create flase and count > 1, generates more html compared to count =0 |
|
52 | + $html3 = get_module_title("Users", "Users Home", false, 2 ); |
|
53 | + $this->assertGreaterThan(0,strlen($html3)); |
|
54 | + $this->assertNotFalse(strpos($html3,"Users")); |
|
55 | + $this->assertNotFalse(strpos($html3,"Users Home")); |
|
56 | + $this->assertGreaterThan(strlen($html2),strlen($html3)); |
|
57 | + $this->assertGreaterThan(strlen($html3),strlen($html1)); |
|
58 | + |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - public function testgetClassicModuleTitle() |
|
63 | - { |
|
64 | - //execute the method and test if it returns html and contains the values provided in parameters |
|
62 | + public function testgetClassicModuleTitle() |
|
63 | + { |
|
64 | + //execute the method and test if it returns html and contains the values provided in parameters |
|
65 | 65 | |
66 | - //with show_create false, generates less html |
|
67 | - $html1 = getClassicModuleTitle("users", Array('Users Home')); |
|
68 | - $this->assertGreaterThan(0,strlen($html1)); |
|
69 | - $this->assertNotFalse(strpos($html1,"Users Home")); |
|
66 | + //with show_create false, generates less html |
|
67 | + $html1 = getClassicModuleTitle("users", Array('Users Home')); |
|
68 | + $this->assertGreaterThan(0,strlen($html1)); |
|
69 | + $this->assertNotFalse(strpos($html1,"Users Home")); |
|
70 | 70 | |
71 | 71 | |
72 | - //with show_create true, generates more html |
|
73 | - $html2 = getClassicModuleTitle("users", Array('Users Home'),true); |
|
74 | - $this->assertGreaterThan(0,strlen($html2)); |
|
75 | - $this->assertNotFalse(strpos($html2,"Users Home")); |
|
76 | - $this->assertGreaterThan(strlen($html1),strlen($html2)); |
|
72 | + //with show_create true, generates more html |
|
73 | + $html2 = getClassicModuleTitle("users", Array('Users Home'),true); |
|
74 | + $this->assertGreaterThan(0,strlen($html2)); |
|
75 | + $this->assertNotFalse(strpos($html2,"Users Home")); |
|
76 | + $this->assertGreaterThan(strlen($html1),strlen($html2)); |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - public function testinsert_popup_header() |
|
82 | - { |
|
83 | - //execute the method and test if it returns html/JS |
|
81 | + public function testinsert_popup_header() |
|
82 | + { |
|
83 | + //execute the method and test if it returns html/JS |
|
84 | 84 | |
85 | - //with includeJS true, generates more html |
|
86 | - ob_start(); |
|
87 | - insert_popup_header(); |
|
88 | - $renderedContent1 = ob_get_contents(); |
|
89 | - ob_end_clean(); |
|
90 | - $this->assertGreaterThan(0,strlen($renderedContent1)); |
|
85 | + //with includeJS true, generates more html |
|
86 | + ob_start(); |
|
87 | + insert_popup_header(); |
|
88 | + $renderedContent1 = ob_get_contents(); |
|
89 | + ob_end_clean(); |
|
90 | + $this->assertGreaterThan(0,strlen($renderedContent1)); |
|
91 | 91 | |
92 | 92 | |
93 | - //with includeJS false, generates less html |
|
94 | - ob_start(); |
|
95 | - insert_popup_header('',false); |
|
96 | - $renderedContent2 = ob_get_contents(); |
|
97 | - ob_end_clean(); |
|
98 | - $this->assertGreaterThan(0,strlen($renderedContent2)); |
|
93 | + //with includeJS false, generates less html |
|
94 | + ob_start(); |
|
95 | + insert_popup_header('',false); |
|
96 | + $renderedContent2 = ob_get_contents(); |
|
97 | + ob_end_clean(); |
|
98 | + $this->assertGreaterThan(0,strlen($renderedContent2)); |
|
99 | 99 | |
100 | - $this->assertGreaterThan(strlen($renderedContent2),strlen($renderedContent1)); |
|
100 | + $this->assertGreaterThan(strlen($renderedContent2),strlen($renderedContent1)); |
|
101 | 101 | |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - public function testinsert_popup_footer() |
|
106 | - { |
|
107 | - //execute the method and test if it returns html |
|
105 | + public function testinsert_popup_footer() |
|
106 | + { |
|
107 | + //execute the method and test if it returns html |
|
108 | 108 | |
109 | - ob_start(); |
|
110 | - insert_popup_footer(); |
|
111 | - $renderedContent = ob_get_contents(); |
|
112 | - ob_end_clean(); |
|
113 | - $this->assertGreaterThan(0,strlen($renderedContent)); |
|
109 | + ob_start(); |
|
110 | + insert_popup_footer(); |
|
111 | + $renderedContent = ob_get_contents(); |
|
112 | + ob_end_clean(); |
|
113 | + $this->assertGreaterThan(0,strlen($renderedContent)); |
|
114 | 114 | |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | ?> |
@@ -6,36 +6,36 @@ |
||
6 | 6 | |
7 | 7 | |
8 | 8 | public function testautoload() |
9 | - { |
|
10 | - //execute the method and test if it returns expected values |
|
9 | + { |
|
10 | + //execute the method and test if it returns expected values |
|
11 | 11 | |
12 | - //test with a invalid class . |
|
13 | - $result = SugarAutoLoader::autoload('foo'); |
|
14 | - $this->assertFalse($result); |
|
12 | + //test with a invalid class . |
|
13 | + $result = SugarAutoLoader::autoload('foo'); |
|
14 | + $this->assertFalse($result); |
|
15 | 15 | |
16 | - //test with a valid class out of autoload mappings. |
|
17 | - $result = SugarAutoLoader::autoload('SugarArray'); |
|
18 | - $this->assertFalse($result); |
|
16 | + //test with a valid class out of autoload mappings. |
|
17 | + $result = SugarAutoLoader::autoload('SugarArray'); |
|
18 | + $this->assertFalse($result); |
|
19 | 19 | |
20 | - //test with a valid class registered in autoload mappings |
|
21 | - $result = SugarAutoLoader::autoload('User'); |
|
22 | - $this->assertTrue($result); |
|
20 | + //test with a valid class registered in autoload mappings |
|
21 | + $result = SugarAutoLoader::autoload('User'); |
|
22 | + $this->assertTrue($result); |
|
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - public function testloadAll(){ |
|
27 | + public function testloadAll(){ |
|
28 | 28 | |
29 | - //execute the method and check if it works and doesn't throws an exception |
|
30 | - //this method only includes file so there is no output to test. |
|
31 | - try { |
|
32 | - SugarAutoLoader::loadAll(); |
|
33 | - $this->assertTrue(TRUE); |
|
34 | - } catch (Exception $e) { |
|
35 | - $this->fail(); |
|
36 | - } |
|
29 | + //execute the method and check if it works and doesn't throws an exception |
|
30 | + //this method only includes file so there is no output to test. |
|
31 | + try { |
|
32 | + SugarAutoLoader::loadAll(); |
|
33 | + $this->assertTrue(TRUE); |
|
34 | + } catch (Exception $e) { |
|
35 | + $this->fail(); |
|
36 | + } |
|
37 | 37 | |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | ?> |
@@ -5,22 +5,22 @@ |
||
5 | 5 | { |
6 | 6 | |
7 | 7 | |
8 | - public function testunzip(){ |
|
9 | - $this->markTestIncomplete('Can Not be implemented'); |
|
10 | - } |
|
8 | + public function testunzip(){ |
|
9 | + $this->markTestIncomplete('Can Not be implemented'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function testunzip_file(){ |
|
13 | - $this->markTestIncomplete('Can Not be implemented'); |
|
14 | - } |
|
12 | + public function testunzip_file(){ |
|
13 | + $this->markTestIncomplete('Can Not be implemented'); |
|
14 | + } |
|
15 | 15 | |
16 | - public function testzip_dir(){ |
|
17 | - $this->markTestIncomplete('Can Not be implemented'); |
|
18 | - } |
|
16 | + public function testzip_dir(){ |
|
17 | + $this->markTestIncomplete('Can Not be implemented'); |
|
18 | + } |
|
19 | 19 | |
20 | 20 | |
21 | - public function testzip_files_list() |
|
22 | - { |
|
23 | - $this->markTestIncomplete('Can Not be implemented'); |
|
24 | - } |
|
21 | + public function testzip_files_list() |
|
22 | + { |
|
23 | + $this->markTestIncomplete('Can Not be implemented'); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |