mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-22 23:17:12 +01:00
Fixes #14184: Module service locator now falls back to its parent module service locator in case component isn't found
This commit is contained in:
@@ -9,6 +9,8 @@ namespace yiiunit\framework\base;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Controller;
|
||||
use yii\base\Module;
|
||||
use yii\base\Object;
|
||||
use yiiunit\TestCase;
|
||||
|
||||
/**
|
||||
@@ -84,6 +86,17 @@ class ModuleTest extends TestCase
|
||||
$this->assertNotNull(Yii::$app->controller->action);
|
||||
$this->assertEquals('test/test-controller1/test1', Yii::$app->controller->action->uniqueId);
|
||||
}
|
||||
|
||||
|
||||
public function testServiceLocatorTraversal()
|
||||
{
|
||||
$parent = new Module('parent');
|
||||
$child = new Module('child', $parent);
|
||||
$grandchild = new Module('grandchild', $child);
|
||||
|
||||
$parent->set('test', new Object());
|
||||
$this->assertInstanceOf(Object::className(), $grandchild->get('test'));
|
||||
}
|
||||
}
|
||||
|
||||
class TestModule extends \yii\base\Module
|
||||
|
||||
Reference in New Issue
Block a user