@@ -4,6 +4,8 @@ class Loader_test extends CI_TestCase {
4
4
5
5
private $ ci_obj ;
6
6
7
+ private $ realAssertObjectHasProperty ;
8
+
7
9
public function set_up ()
8
10
{
9
11
// Instantiate a new loader
@@ -16,6 +18,12 @@ public function set_up()
16
18
// Set subclass prefix
17
19
$ this ->prefix = 'MY_ ' ;
18
20
$ this ->ci_set_config ('subclass_prefix ' , $ this ->prefix );
21
+
22
+ // assertObjectHasAttribute() is deprecated and will be removed in PHPUnit 10.
23
+ // It was replaced by assertObjectHasProperty() in phpunit 10.1.0+
24
+ $ this ->realAssertObjectHasProperty = method_exists ($ this , 'assertObjectHasProperty ' )
25
+ ? 'assertObjectHasProperty '
26
+ : 'assertObjectHasAttribute ' ;
19
27
}
20
28
21
29
// --------------------------------------------------------------------
@@ -36,7 +44,7 @@ public function test_library()
36
44
// Test loading as an array.
37
45
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library (array ($ lib )));
38
46
$ this ->assertTrue (class_exists ($ class ), $ class .' does not exist ' );
39
- $ this -> assertObjectHasAttribute ($ lib , $ this ->ci_obj );
47
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ lib , $ this ->ci_obj ) );
40
48
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ lib );
41
49
42
50
// Create library in VFS
@@ -88,21 +96,21 @@ public function test_library_extension()
88
96
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library ($ lib ));
89
97
$ this ->assertTrue (class_exists ($ class ), $ class .' does not exist ' );
90
98
$ this ->assertTrue (class_exists ($ ext ), $ ext .' does not exist ' );
91
- $ this -> assertObjectHasAttribute ($ name , $ this ->ci_obj );
99
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ name , $ this ->ci_obj ) );
92
100
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ name );
93
101
$ this ->assertInstanceOf ($ ext , $ this ->ci_obj ->$ name );
94
102
95
103
// Test reloading with object name
96
104
$ obj = 'exttest ' ;
97
105
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library ($ lib , NULL , $ obj ));
98
- $ this -> assertObjectHasAttribute ($ obj , $ this ->ci_obj );
106
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ obj , $ this ->ci_obj ) );
99
107
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ obj );
100
108
$ this ->assertInstanceOf ($ ext , $ this ->ci_obj ->$ obj );
101
109
102
110
// Test reloading
103
111
unset($ this ->ci_obj ->$ name );
104
112
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library ($ lib ));
105
- $ this -> assertObjectHasAttribute ($ name , $ this ->ci_obj );
113
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ name , $ this ->ci_obj ) );
106
114
107
115
// Create baseless library
108
116
$ name = 'ext_baseless_lib ' ;
@@ -140,7 +148,7 @@ public function test_library_config()
140
148
$ obj = 'testy ' ;
141
149
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library ($ lib , NULL , $ obj ));
142
150
$ this ->assertTrue (class_exists ($ class ), $ class .' does not exist ' );
143
- $ this -> assertObjectHasAttribute ($ obj , $ this ->ci_obj );
151
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ obj , $ this ->ci_obj ) );
144
152
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ obj );
145
153
$ this ->assertEquals ($ cfg , $ this ->ci_obj ->$ obj ->config );
146
154
@@ -172,7 +180,7 @@ public function test_load_library_in_application_dir()
172
180
173
181
// Was the model class instantiated.
174
182
$ this ->assertTrue (class_exists ($ class ), $ class .' does not exist ' );
175
- $ this -> assertObjectHasAttribute ($ lib , $ this ->ci_obj );
183
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ lib , $ this ->ci_obj ) );
176
184
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ lib );
177
185
}
178
186
@@ -193,13 +201,13 @@ class_exists('CI_Driver_Library', TRUE);
193
201
// Test loading as an array.
194
202
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->driver (array ($ driver )));
195
203
$ this ->assertTrue (class_exists ($ class ), $ class .' does not exist ' );
196
- $ this -> assertObjectHasAttribute ($ driver , $ this ->ci_obj );
204
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ driver , $ this ->ci_obj ) );
197
205
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ driver );
198
206
199
207
// Test loading as a library with a name
200
208
$ obj = 'testdrive ' ;
201
209
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->library ($ driver , NULL , $ obj ));
202
- $ this -> assertObjectHasAttribute ($ obj , $ this ->ci_obj );
210
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ obj , $ this ->ci_obj ) );
203
211
$ this ->assertInstanceOf ($ class , $ this ->ci_obj ->$ obj );
204
212
205
213
// Test a string given to params
@@ -222,7 +230,7 @@ public function test_models()
222
230
223
231
// Was the model class instantiated.
224
232
$ this ->assertTrue (class_exists ($ model ));
225
- $ this -> assertObjectHasAttribute ($ model , $ this ->ci_obj );
233
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ model , $ this ->ci_obj ) );
226
234
227
235
// Test no model given
228
236
$ this ->assertInstanceOf ('CI_Loader ' , $ this ->load ->model ('' ));
@@ -248,8 +256,8 @@ public function test_model_subdir()
248
256
249
257
// Was the model class instantiated?
250
258
$ this ->assertTrue (class_exists ($ model ));
251
- $ this -> assertObjectHasAttribute ($ name , $ this ->ci_obj );
252
- $ this -> assertObjectHasAttribute ($ name , $ this ->ci_obj );
259
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ name , $ this ->ci_obj ) );
260
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ name , $ this ->ci_obj ) );
253
261
$ this ->assertInstanceOf ($ base , $ this ->ci_obj ->$ name );
254
262
$ this ->assertInstanceOf ($ model , $ this ->ci_obj ->$ name );
255
263
@@ -607,17 +615,17 @@ public function test_initialize()
607
615
608
616
// Verify library
609
617
$ this ->assertTrue (class_exists ($ lib_class ), $ lib_class .' does not exist ' );
610
- $ this -> assertObjectHasAttribute ($ lib , $ this ->ci_obj );
618
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ lib , $ this ->ci_obj ) );
611
619
$ this ->assertInstanceOf ($ lib_class , $ this ->ci_obj ->$ lib );
612
620
613
621
// Verify driver
614
622
$ this ->assertTrue (class_exists ($ drv_class ), $ drv_class .' does not exist ' );
615
- $ this -> assertObjectHasAttribute ($ drv , $ this ->ci_obj );
623
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ drv , $ this ->ci_obj ) );
616
624
$ this ->assertInstanceOf ($ drv_class , $ this ->ci_obj ->$ drv );
617
625
618
626
// Verify model
619
627
$ this ->assertTrue (class_exists ($ model ), $ model .' does not exist ' );
620
- $ this -> assertObjectHasAttribute ($ model , $ this ->ci_obj );
628
+ call_user_func_array ( array ( $ this , $ this -> realAssertObjectHasProperty ), array ($ model , $ this ->ci_obj ) );
621
629
$ this ->assertInstanceOf ($ model , $ this ->ci_obj ->$ model );
622
630
623
631
// Verify config calls
0 commit comments