Skip to content

Commit f5928ea

Browse files
committed
test: fix unit test count checking
1 parent e4e8488 commit f5928ea

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

tests/task/populate_objects_filesize_test.php

+8-12
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
*/
2828
class populate_objects_filesize_test extends \tool_objectfs\tests\testcase {
2929

30-
/**
31-
* This method runs before every test.
32-
*/
33-
public function setUp(): void {
34-
$this->resetAfterTest();
35-
}
36-
3730
/**
3831
* Test multiple objects have their filesize updated.
3932
*/
@@ -179,7 +172,8 @@ public function test_that_non_null_values_are_not_updated() {
179172
*/
180173
public function test_orphaned_objects_are_not_updated() {
181174
global $DB;
182-
$objects = $DB->get_records('tool_objectfs_objects');
175+
$numstart = $DB->count_records('tool_objectfs_objects');
176+
183177
$file1 = $this->create_local_file("Test 1");
184178
$this->create_local_file("Test 2");
185179
$this->create_local_file("Test 3");
@@ -203,15 +197,17 @@ public function test_orphaned_objects_are_not_updated() {
203197
});
204198

205199
// 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);
208202
}
209203

210204
/**
211205
* Tests objects with an error for location are not updated to prevent unexpected behaviour.
212206
*/
213207
public function test_objects_with_error_are_not_updated() {
214208
global $DB;
209+
$numstart = $DB->count_records('tool_objectfs_objects');
210+
215211
$file1 = $this->create_local_file("Test 1");
216212
$this->create_local_file("Test 2");
217213
$this->create_local_file("Test 3");
@@ -235,7 +231,7 @@ public function test_objects_with_error_are_not_updated() {
235231
});
236232

237233
// 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);
240236
}
241237
}

0 commit comments

Comments
 (0)