27
27
*/
28
28
class populate_objects_filesize_test extends \tool_objectfs \tests \testcase {
29
29
30
- /**
31
- * This method runs before every test.
32
- */
33
- public function setUp (): void {
34
- $ this ->resetAfterTest ();
35
- }
36
-
37
30
/**
38
31
* Test multiple objects have their filesize updated.
39
32
*/
@@ -179,7 +172,8 @@ public function test_that_non_null_values_are_not_updated() {
179
172
*/
180
173
public function test_orphaned_objects_are_not_updated () {
181
174
global $ DB ;
182
- $ objects = $ DB ->get_records ('tool_objectfs_objects ' );
175
+ $ numstart = $ DB ->count_records ('tool_objectfs_objects ' );
176
+
183
177
$ file1 = $ this ->create_local_file ("Test 1 " );
184
178
$ this ->create_local_file ("Test 2 " );
185
179
$ this ->create_local_file ("Test 3 " );
@@ -203,15 +197,17 @@ public function test_orphaned_objects_are_not_updated() {
203
197
});
204
198
205
199
// Test that 4 records have now been updated.
206
- $ this ->assertCount (5 , $ objects );
207
- $ this ->assertCount (4 , $ updatedobjects );
200
+ $ this ->assertEquals (5 , count ( $ objects) - $ numstart );
201
+ $ this ->assertEquals (4 , count ( $ updatedobjects) - $ numstart );
208
202
}
209
203
210
204
/**
211
205
* Tests objects with an error for location are not updated to prevent unexpected behaviour.
212
206
*/
213
207
public function test_objects_with_error_are_not_updated () {
214
208
global $ DB ;
209
+ $ numstart = $ DB ->count_records ('tool_objectfs_objects ' );
210
+
215
211
$ file1 = $ this ->create_local_file ("Test 1 " );
216
212
$ this ->create_local_file ("Test 2 " );
217
213
$ this ->create_local_file ("Test 3 " );
@@ -235,7 +231,7 @@ public function test_objects_with_error_are_not_updated() {
235
231
});
236
232
237
233
// Test that 4 records have now been updated.
238
- $ this ->assertCount (5 , $ objects );
239
- $ this ->assertCount (4 , $ updatedobjects );
234
+ $ this ->assertEquals (5 , count ( $ objects) - $ numstart );
235
+ $ this ->assertEquals (4 , count ( $ updatedobjects) - $ numstart );
240
236
}
241
237
}
0 commit comments