Skip to content

Commit

Permalink
Test: BaseService & Config improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-parry committed Mar 11, 2019
1 parent a0828b5 commit 9592877
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
2 changes: 2 additions & 0 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ protected static function discoverServices(string $name, array $arguments)

if (empty($files))
{
// no files at all found - this would be really, really bad
return null;
}

Expand All @@ -271,6 +272,7 @@ protected static function discoverServices(string $name, array $arguments)

if (! static::$services)
{
// we found stuff, but no services - this would be really bad
return null;
}

Expand Down
17 changes: 15 additions & 2 deletions tests/system/Config/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace CodeIgniter\Config;
<?php
namespace CodeIgniter\Config;

use Config\DocTypes;

Expand All @@ -23,7 +24,7 @@ public function testCreateInvalidInstance()

public function testCreateSharedInstance()
{
$Config = Config::get('DocTypes' );
$Config = Config::get('DocTypes');
$Config2 = Config::get('Config\\DocTypes');

$this->assertTrue($Config === $Config2);
Expand All @@ -35,4 +36,16 @@ public function testCreateNonConfig()

$this->assertNull($Config);
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testInjection()
{
Config::reset();
Config::injectMock('Banana', '\stdClass');
$this->assertNotNull(Config::get('Banana'));
}

}
17 changes: 0 additions & 17 deletions tests/system/Config/ServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,6 @@ public function testCallStaticDirectly()
$this->assertInstanceOf(\CodeIgniter\Session\Session::class, $actual);
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function testNothingToDiscover()
{
$service = new \Tests\Support\Config\MockServices();

// doctor the autoloader & filelocator so they don't see anything useful
$autoloader = new \Tests\Support\Config\MockAutoload();
$this->locator = new \CodeIgniter\Autoloader\FileLocator($autoloader);

// __callStatic should kick in for this but fail
$actual = MockServices::SeSsIoNs(null, false);
$this->assertNull($actual);
}

/**
* @runInSeparateProcess
* @preserveGlobalState disabled
Expand Down

0 comments on commit 9592877

Please sign in to comment.