From 51101d95053b07307c514a7ab5fe4fc1ebc6e5d5 Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Mon, 29 Jul 2024 09:10:07 +1000 Subject: [PATCH] test: fix unit test count checking --- tests/task/populate_objects_filesize_test.php | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/task/populate_objects_filesize_test.php b/tests/task/populate_objects_filesize_test.php index dd1402e1..a02f9372 100644 --- a/tests/task/populate_objects_filesize_test.php +++ b/tests/task/populate_objects_filesize_test.php @@ -27,13 +27,6 @@ */ class populate_objects_filesize_test extends \tool_objectfs\tests\testcase { - /** - * This method runs before every test. - */ - public function setUp(): void { - $this->resetAfterTest(); - } - /** * Test multiple objects have their filesize updated. */ @@ -179,7 +172,8 @@ public function test_that_non_null_values_are_not_updated() { */ public function test_orphaned_objects_are_not_updated() { global $DB; - $objects = $DB->get_records('tool_objectfs_objects'); + $numstart = $DB->count_records('tool_objectfs_objects'); + $file1 = $this->create_local_file("Test 1"); $this->create_local_file("Test 2"); $this->create_local_file("Test 3"); @@ -203,8 +197,8 @@ public function test_orphaned_objects_are_not_updated() { }); // Test that 4 records have now been updated. - $this->assertCount(5, $objects); - $this->assertCount(4, $updatedobjects); + $this->assertEquals(5, count($objects) - $numstart); + $this->assertEquals(4, count($updatedobjects) - $numstart); } /** @@ -212,6 +206,8 @@ public function test_orphaned_objects_are_not_updated() { */ public function test_objects_with_error_are_not_updated() { global $DB; + $numstart = $DB->count_records('tool_objectfs_objects'); + $file1 = $this->create_local_file("Test 1"); $this->create_local_file("Test 2"); $this->create_local_file("Test 3"); @@ -235,7 +231,7 @@ public function test_objects_with_error_are_not_updated() { }); // Test that 4 records have now been updated. - $this->assertCount(5, $objects); - $this->assertCount(4, $updatedobjects); + $this->assertEquals(5, count($objects) - $numstart); + $this->assertEquals(4, count($updatedobjects) - $numstart); } }