"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/framework/di/ContainerTest.php" between
yii2-2.0.35.tar.gz and yii2-2.0.36.tar.gz

About: Yii 2 is a high-performance component-based PHP framework for developing large-scale Web applications (source).

ContainerTest.php  (yii2-2.0.35):ContainerTest.php  (yii2-2.0.36)
skipping to change at line 19 skipping to change at line 19
use Yii; use Yii;
use yii\di\Container; use yii\di\Container;
use yii\di\Instance; use yii\di\Instance;
use yii\validators\NumberValidator; use yii\validators\NumberValidator;
use yiiunit\data\ar\Cat; use yiiunit\data\ar\Cat;
use yiiunit\data\ar\Order; use yiiunit\data\ar\Order;
use yiiunit\data\ar\Type; use yiiunit\data\ar\Type;
use yiiunit\framework\di\stubs\Bar; use yiiunit\framework\di\stubs\Bar;
use yiiunit\framework\di\stubs\BarSetter; use yiiunit\framework\di\stubs\BarSetter;
use yiiunit\framework\di\stubs\Corge;
use yiiunit\framework\di\stubs\Foo; use yiiunit\framework\di\stubs\Foo;
use yiiunit\framework\di\stubs\FooProperty; use yiiunit\framework\di\stubs\FooProperty;
use yiiunit\framework\di\stubs\Qux; use yiiunit\framework\di\stubs\Qux;
use yiiunit\framework\di\stubs\QuxInterface; use yiiunit\framework\di\stubs\QuxInterface;
use yiiunit\framework\di\stubs\QuxFactory; use yiiunit\framework\di\stubs\QuxFactory;
use yiiunit\TestCase; use yiiunit\TestCase;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0 * @since 2.0
skipping to change at line 353 skipping to change at line 354
], ],
], ],
]); ]);
$bar = $container->get('bar'); $bar = $container->get('bar');
$this->assertInstanceOf(Bar::className(), $bar); $this->assertInstanceOf(Bar::className(), $bar);
$qux = $bar->qux; $qux = $bar->qux;
$this->assertInstanceOf(Qux::className(), $qux); $this->assertInstanceOf(Qux::className(), $qux);
$this->assertSame(42, $qux->a); $this->assertSame(42, $qux->a);
} }
public function testReferencesInArrayInDependencies()
{
$quxInterface = 'yiiunit\framework\di\stubs\QuxInterface';
$container = new Container();
$container->setSingletons([
$quxInterface => [
'class' => Qux::className(),
'a' => 42,
],
'qux' => Instance::of($quxInterface),
'bar' => [
'class' => Bar::className(),
],
'corge' => [
'__class' => Corge::className(),
'__construct()' => [
[
'qux' => Instance::of('qux'),
'bar' => Instance::of('bar'),
'q33' => new Qux(33),
],
],
],
]);
$corge = $container->get('corge');
$this->assertInstanceOf(Corge::className(), $corge);
$qux = $corge->map['qux'];
$this->assertInstanceOf(Qux::className(), $qux);
$this->assertSame(42, $qux->a);
$bar = $corge->map['bar'];
$this->assertInstanceOf(Bar::className(), $bar);
$this->assertSame($qux, $bar->qux);
$q33 = $corge->map['q33'];
$this->assertInstanceOf(Qux::className(), $q33);
$this->assertSame(33, $q33->a);
}
public function testGetByInstance() public function testGetByInstance()
{ {
$container = new Container(); $container = new Container();
$container->setSingletons([ $container->setSingletons([
'one' => Qux::className(), 'one' => Qux::className(),
'two' => Instance::of('one'), 'two' => Instance::of('one'),
]); ]);
$one = $container->get(Instance::of('one')); $one = $container->get(Instance::of('one'));
$two = $container->get(Instance::of('two')); $two = $container->get(Instance::of('two'));
$this->assertInstanceOf(Qux::className(), $one); $this->assertInstanceOf(Qux::className(), $one);
 End of changes. 2 change blocks. 
0 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)