mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Add failing test to show that overloaded extensions are broken in Extensible
This commit is contained in:
parent
d1281a571a
commit
55e79ffdfd
@ -21,12 +21,13 @@ use SilverStripe\Core\Tests\Injector\InjectorTest\NeedsBothCirculars;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\NewRequirementsBackend;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\OriginalRequirementsBackend;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\OtherTestObject;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\SomeCustomisedExtension;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\SomeExtension;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\TestObject;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\TestSetterInjections;
|
||||
use SilverStripe\Core\Tests\Injector\InjectorTest\TestStaticInjections;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use stdClass;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
define('TEST_SERVICES', __DIR__ . '/AopProxyServiceTest');
|
||||
|
||||
@ -1047,4 +1048,23 @@ class InjectorTest extends SapphireTest
|
||||
Injector::unnest();
|
||||
$this->nestingLevel--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that overloaded extensions work, see {@link Extensible::getExtensionInstance()}
|
||||
*/
|
||||
public function testExtendedExtensions()
|
||||
{
|
||||
Config::modify()
|
||||
->set(Injector::class, SomeExtension::class, [
|
||||
'class' => SomeCustomisedExtension::class,
|
||||
])
|
||||
->merge(Member::class, 'extensions', [
|
||||
SomeExtension::class,
|
||||
]);
|
||||
|
||||
/** @var Member|SomeExtension $member */
|
||||
$member = new Member();
|
||||
$this->assertTrue($member->hasExtension(SomeExtension::class));
|
||||
$this->assertSame('bar', $member->someMethod());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Core\Tests\Injector\InjectorTest;
|
||||
|
||||
class SomeCustomisedExtension extends SomeExtension
|
||||
{
|
||||
public function someMethod()
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
13
tests/php/Core/Injector/InjectorTest/SomeExtension.php
Normal file
13
tests/php/Core/Injector/InjectorTest/SomeExtension.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Core\Tests\Injector\InjectorTest;
|
||||
|
||||
use SilverStripe\ORM\DataExtension;
|
||||
|
||||
class SomeExtension extends DataExtension
|
||||
{
|
||||
public function someMethod()
|
||||
{
|
||||
return 'foo';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user