Refactoring

This commit is contained in:
gamonoid
2017-09-03 20:39:22 +02:00
parent af40881847
commit a7274d3cfd
5075 changed files with 238202 additions and 16291 deletions

View File

@@ -0,0 +1,30 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
use League\Container\ContainerAwareInterface;
use League\Container\ContainerAwareTrait;
class CliGuy extends \Codeception\Actor
{
use _generated\CliGuyActions;
/**
* Define custom actions here
*/
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Codeception\Module;
use Robo\Robo;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\NullOutput;
use League\Container\ContainerAwareInterface;
use League\Container\ContainerAwareTrait;
class CliHelper extends \Codeception\Module implements ContainerAwareInterface
{
use ContainerAwareTrait;
use SeeInOutputTrait;
use \Robo\LoadAllTasks {
task as public;
taskExec as public;
taskExecStack as public;
taskWriteToFile as public;
taskReplaceInFile as public;
taskConcat as public;
taskTmpFile as public;
taskCleanDir as public;
taskCopyDir as public;
taskGenTask as public;
taskDeleteDir as public;
taskFlattenDir as public;
taskFilesystemStack as public;
taskTmpDir as public;
taskMinify as public;
_copyDir as public shortcutCopyDir;
_mirrorDir as public shortcutMirrorDir;
_tmpDir as public shortcutTmpDir;
taskPack as public;
taskExtract as public;
}
public function collectionBuilder()
{
$tasks = new \Robo\Tasks();
$builder = $this->getContainer()->get('collectionBuilder', [$tasks]);
$tasks->setBuilder($builder);
return $builder;
}
public function seeDirFound($dir)
{
$this->assertTrue(is_dir($dir) && file_exists($dir), "Directory does not exist");
}
public function _before(\Codeception\TestCase $test) {
$container = new \League\Container\Container();
$this->initSeeInOutputTrait($container);
Robo::setContainer($container);
$this->setContainer($container);
$this->getModule('Filesystem')->copyDir(codecept_data_dir().'claypit', codecept_data_dir().'sandbox');
}
public function _after(\Codeception\TestCase $test) {
$this->getModule('Filesystem')->deleteDir(codecept_data_dir().'sandbox');
$this->getContainer()->add('output', new ConsoleOutput());
chdir(codecept_root_dir());
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
*
* @SuppressWarnings(PHPMD)
*/
class CodeGuy extends \Codeception\Actor
{
use _generated\CodeGuyActions;
/**
* Define custom actions here
*/
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
use Robo\Robo;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
class CodeHelper extends \Codeception\Module
{
use SeeInOutputTrait;
protected static $container;
public function _before(\Codeception\TestCase $test)
{
static::$container = new \League\Container\Container();
Robo::setContainer(static::$container);
$this->initSeeInOutputTrait(static::$container);
}
public function _after(\Codeception\TestCase $test)
{
// Ensure that $stopOnFail global static is reset, as tests
// that set it to true will force an exception, and therefor
// will not have a chance to clean this up.
\Robo\Result::$stopOnFail = false;
\AspectMock\Test::clean();
$consoleOutput = new ConsoleOutput();
static::$container->add('output', $consoleOutput);
static::$container->add('logger', new \Consolidation\Log\Logger($consoleOutput));
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Codeception\Module;
use Robo\Robo;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
trait SeeInOutputTrait
{
protected $testPrinter;
protected $capturedOutput;
protected $logger;
public function initSeeInOutputTrait($container, $input = null)
{
$this->capturedOutput = '';
$this->testPrinter = new BufferedOutput(OutputInterface::VERBOSITY_DEBUG);
$app = Robo::createDefaultApplication();
$config = new \Robo\Config();
\Robo\Robo::configureContainer($container, $app, $config, $input, $this->testPrinter);
// Set the application dispatcher
$app->setDispatcher($container->get('eventDispatcher'));
$this->logger = $container->get('logger');
}
public function capturedOutputStream()
{
return $this->testPrinter;
}
public function logger()
{
return $this->logger;
}
protected function accumulate()
{
$this->capturedOutput .= $this->testPrinter->fetch();
return $this->capturedOutput;
}
public function seeInOutput($value)
{
$output = $this->accumulate();
$this->assertContains($value, $output);
}
public function doNotSeeInOutput($value)
{
$output = $this->accumulate();
$this->assertNotContains($value, $output);
}
public function seeOutputEquals($value)
{
$output = $this->accumulate();
$this->assertEquals($value, $output);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class TestHelper extends \Codeception\Module
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class WebHelper extends \Codeception\Module
{
}