mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-73826 phpunit: Allow curl mock responses to handle empty strings
Before this commit, is_empty() was being applied before returning the mock response. But we want to be able to mock the empty response for some tests, hence moving the condition to null/isset, that is the value that array_pop() returns where there aren't more elements in the array. With that change performed, we can test lti_load_cartridge() with empty responses, hence adding a new test for that.
This commit is contained in:
parent
64969e82d7
commit
d66a5316ae
2 changed files with 16 additions and 1 deletions
|
@ -1945,6 +1945,20 @@ MwIDAQAB
|
|||
$this->assertEquals(16, $countwithproxyid); // 1 type, 15 proxies.
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that empty curl responses lead to the proper moodle_exception, not to XML ValueError.
|
||||
*
|
||||
* @covers ::lti_load_cartridge()
|
||||
*/
|
||||
public function test_empty_reponse_lti_load_cartridge() {
|
||||
// Mock the curl response to empty string, this is hardly
|
||||
// reproducible in real life (only Windows + GHA).
|
||||
\curl::mock_response('');
|
||||
|
||||
$this->expectException(\moodle_exception::class);
|
||||
lti_load_cartridge('http://example.com/mocked/empty/response', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an LTI Tool.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue