PHP Classes

File: testCest.php

Recommend this page to a friend!
  Classes of goo  >  FContainer  >  testCest.php  >  Download  
File: testCest.php
Role: Unit test script
Content type: text/plain
Description: unittest with codeception
Class: FContainer
Simple dependency injection container
Author: By
Last change:
Date: 7 years ago
Size: 1,517 bytes
 

Contents

Class file image Download
<?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');
    }

}

For more information send a message to info at phpclasses dot org.