MDL-86495 core: Improve PHPUnit for IPLookup
This commit is contained in:
@@ -55,8 +55,6 @@ final class geoip_test extends \advanced_testcase {
|
||||
$this->markTestSkipped('External geo tests are disabled.');
|
||||
}
|
||||
$this->resetAfterTest();
|
||||
// Store the old value to restore later.
|
||||
$oldvalue = $CFG->geopluginapikey;
|
||||
$CFG->geopluginapikey = TEST_GEOIP_APIKEY;
|
||||
$this->setup_geoip2file();
|
||||
|
||||
@@ -75,9 +73,6 @@ final class geoip_test extends \advanced_testcase {
|
||||
$this->assertIsString($result['title'][0]);
|
||||
$this->assertIsString($result['title'][1]);
|
||||
$this->assertNull($result['error']);
|
||||
|
||||
// Restore the old value.
|
||||
$CFG->geopluginapikey = $oldvalue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace core;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
final class geoplugin_test extends \advanced_testcase {
|
||||
/** @var string Current Geoplugin API key. */
|
||||
private string $currentgeopluginapikey = '';
|
||||
|
||||
/**
|
||||
* Load required test libraries
|
||||
@@ -52,17 +50,9 @@ final class geoplugin_test extends \advanced_testcase {
|
||||
if (!defined('TEST_GEOIP_APIKEY') || empty(TEST_GEOIP_APIKEY)) {
|
||||
$this->markTestSkipped('External geo tests are disabled.');
|
||||
}
|
||||
// Store the old value to restore later.
|
||||
$this->currentgeopluginapikey = $CFG->geopluginapikey;
|
||||
$CFG->geopluginapikey = TEST_GEOIP_APIKEY;
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
global $CFG;
|
||||
$CFG->geopluginapikey = $this->currentgeopluginapikey;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IPv4 address
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user