PHP Classes

File: src/templates/codeception2.php

Recommend this page to a friend!
  Classes of Insolita   Yii2 SkeleTest   src/templates/codeception2.php   Download  
File: src/templates/codeception2.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Yii2 SkeleTest
Generate file skeletons to test PHP projects
Author: By
Last change:
Date: 15 days ago
Size: 1,963 bytes
 

Contents

Class file image Download
<?php
/**
 * @var array $methods
 * @var \insolita\skeletest\entity\FileClass $testFile
 * @var \insolita\skeletest\entity\AppConfig $app
 * @var \ReflectionClass $reflection
 * @var bool $useAccessibleTrait
 **/
echo "<?php".PHP_EOL;
echo
"namespace {$testFile->getNamespace()};".PHP_EOL.PHP_EOL;
?>
use Codeception\Test\Unit;
use Codeception\Specify;
use Codeception\Util\Stub;
use <?=$reflection->getName();?>;
<?php if($useAccessibleTrait===true):?>
use insolita\skeletest\AccessibleMethodTrait;
<?php endif;?>
<?php
if($app->getTesterClass()):?>
use <?=$app->getTesterClass()?>;
<?php endif;?>
/**
* Class <?=$testFile->getName().PHP_EOL ?>
* Test for <?=$reflection->getName().PHP_EOL?>
**/
class <?= $testFile->getName() ?> extends Unit
{
    use Specify;
<?php if($useAccessibleTrait===true):?>
use AccessibleMethodTrait;
<?php endif;?>
<?php
if($app->getTesterClass()):?>
/**
    * @var <?=\yii\helpers\StringHelper::basename($app->getTesterClass())?>
*/
    protected $tester;

    protected function _before()
    {
        $this->tester->haveFixtures([]);
    }
<?php else:?>
protected function _before()
    {
         //Initialize test
    }
<?php endif;?>

<?php foreach ($methods as $method=>$params):?>
/**
    * Test for <?=$method.PHP_EOL?>
* @see \<?=$params['signature'].PHP_EOL?>
**/
    public function test<?=ucfirst($method)?>()
    {
        $this->markTestIncomplete();
        /**
         * TODO: test <?=$params['signature'].PHP_EOL?>
**/
        $result = $this->getTarget()-><?=$method?>(<?=$params['required']?>);
    }
<?php endforeach;?>

    /**
    * @return <?=$reflection->getShortName()?>|object
    **/
    private function getTarget()
    {
         return \Yii::createObject([
         'class'=><?=$reflection->getShortName()?>::class,
         ],[]);
    }

    private function getStub()
    {
        return Stub::make(<?=$reflection->getShortName()?>::class,[

        ],$this);
    }
}