Skip to content

Commit d477ac0

Browse files
committed
Allow auto-initialize autoloader instance after clear
1 parent f31d605 commit d477ac0

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

system/Config/BaseService.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,19 @@ public static function __callStatic(string $name, array $arguments)
196196

197197
/**
198198
* Reset shared instances and mocks for testing.
199+
*
200+
* @param boolean $init_autoloader Initializes autoloader instance
199201
*/
200-
public static function reset()
202+
public static function reset(bool $init_autoloader = false)
201203
{
202204
static::$mocks = [];
203205

204206
static::$instances = [];
207+
208+
if ($init_autoloader)
209+
{
210+
static::autoloader()->initialize(new \Config\Autoload());
211+
}
205212
}
206213

207214
//--------------------------------------------------------------------

tests/system/Validation/ValidationTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public function setUp()
4343
{
4444
parent::setUp();
4545

46-
// Reset all services instances
47-
Services::reset();
48-
// Initialize the Autoloader... - we need it to search for language files in the locator
49-
Services::autoloader()->initialize(new \Config\Autoload());
46+
Services::reset(true);
5047

5148
$this->validation = new Validation((object) $this->config, \Config\Services::renderer());
5249
$this->validation->reset();

tests/system/View/ParserPluginTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public function setUp()
1515
{
1616
parent::setUp();
1717

18-
\Config\Services::reset();
19-
\Config\Services::autoloader()->initialize(new \Config\Autoload());
18+
\Config\Services::reset(true);
19+
2020
$this->parser = \Config\Services::parser();
2121
$this->validator = \Config\Services::validation();
2222
}

0 commit comments

Comments
 (0)