MDL-79477 tool_moodlenet: better handling of network download test.

We can't assume the presense of `Content-Length` header in response
to a HEAD request. Modify test assertion to account for this.
This commit is contained in:
Paul Holden 2023-09-26 11:14:46 +01:00
parent 83b4c96cad
commit 2aa56c770d
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -98,7 +98,15 @@ class remote_resource_test extends \advanced_testcase {
]
);
$this->assertGreaterThan(0, $remoteres->get_download_size());
// We need to handle size of -1 (missing "Content-Length" header), or where it is set and greater than zero.
$this->assertThat(
$remoteres->get_download_size(),
$this->logicalOr(
$this->equalTo(-1),
$this->greaterThan(0),
),
);
[$path, $name] = $remoteres->download_to_requestdir();
$this->assertIsString($path);
$this->assertEquals('test.html', $name);