Merge pull request #7439 from creative-commoners/pulls/4.0/trim-injector-names

FIX Trim whitespace off names in Injector
This commit is contained in:
Damian Mooyman 2017-10-09 12:31:11 +13:00 committed by GitHub
commit 313f8c7ac3
4 changed files with 11 additions and 5 deletions

View File

@ -1010,7 +1010,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
{
}