<?php
use \UnitTester;
class TestClassUnit
{
public function test()
{
return 'hello world';
}
}
class testCest
{
public function _before(UnitTester $I)
{
}
public function _after(UnitTester $I)
{
}
// tests translator
public function testDiContainer(UnitTester $I)
{
$I->wantTo('Test Dependency injection container');
$C = new FContainer();
$C['simple'] = 'simple var assignment';
$I->assertSame('simple var assignment', $C['simple'], 'check variable assignment');
$C['closure'] = function() {
return 'closure assignment';
};
$I->assertSame('closure assignment', $C['closure'], 'check closure assignment');
$C['closure_inside'] = function($me) {
return $me['closure'];
};
$I->assertSame('closure assignment', $C['closure_inside'], 'check Container access from inside closure');
$C['object'] = new TestClassUnit();
$I->assertTrue($C['object'] instanceof TestClassUnit, 'check assignment and creation of object');
$I->assertSame('hello world', $C['object']->test(), 'check object method call');
$C['object_creation'] = function($me) {
return new TestClassUnit();
};
$I->assertTrue($C['object_creation'] instanceof TestClassUnit, 'check object creation inside closure');
$I->assertSame('hello world', $C['object_creation']->test(), 'check closure from object method call');
}
}
|