Skip to content

Commit

Permalink
test: fix unit test count checking
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhilton committed Aug 4, 2024
1 parent f6ce4dd commit 51101d9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tests/task/populate_objects_filesize_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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");
Expand All @@ -203,15 +197,17 @@ 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);
}

/**
* Tests objects with an error for location are not updated to prevent unexpected behaviour.
*/
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");
Expand All @@ -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);
}
}

0 comments on commit 51101d9

Please sign in to comment.