FIX Trim whitespace off names in Injector

This commit is contained in:
Robbie Averill 2017-10-06 11:11:49 +13:00
parent 16cac4e3bd
commit 3bdc8c7e65
4 changed files with 11 additions and 5 deletions

View File

@ -1024,7 +1024,8 @@ class Injector implements ContainerInterface
$args = $extraArgs;
}
}
return [ $name, $args ];
$name = trim($name);
return [$name, $args];
}
/**

View File

@ -960,6 +960,13 @@ class InjectorTest extends SapphireTest
$injector->get('UnknownService');
}
public function testGetTrimsWhitespaceFromNames()
{
$injector = new Injector;
$this->assertInstanceOf(MyChildClass::class, $injector->get(' ' . MyChildClass::class . ' '));
}
/**
* Test nesting of injector
*/

View File

@ -2,10 +2,9 @@
namespace SilverStripe\Core\Tests\Injector\InjectorTest;
use SilverStripe\Core\Tests\Injector\InjectorTest;
use SilverStripe\Dev\TestOnly;
class MyChildClass extends InjectorTest\MyParentClass implements TestOnly
class MyChildClass extends MyParentClass implements TestOnly
{
}

View File

@ -2,10 +2,9 @@
namespace SilverStripe\Core\Tests\Injector\InjectorTest;
use SilverStripe\Core\Tests\Injector\InjectorTest;
use SilverStripe\Dev\TestOnly;
class MyGrandChildClass extends InjectorTest\MyChildClass implements TestOnly
class MyGrandChildClass extends MyChildClass implements TestOnly
{
}