Exemplo n.º 1
0
 public function checkAfterBeforeClassInTests(CliGuy $I)
 {
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('run order BeforeAfterClassTest.php');
     $I->seeFileFound('order.txt', 'tests/_output');
     $I->seeInThisFile('BIB({[1][2])}');
 }
Exemplo n.º 2
0
 public function useTheMirrorDirShortcut(CliGuy $I)
 {
     $I->wantTo('mirror dir with _mirrorDir shortcut');
     $I->shortcutMirrorDir('box', 'bin');
     $I->seeDirFound('bin');
     $I->seeFileFound('robo.txt', 'bin');
 }
Exemplo n.º 3
0
 public function checkTwoFiles(CliGuy $I)
 {
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('run order --no-exit');
     $I->seeFileFound('order.txt', 'tests/_log');
     $I->seeInThisFile("IBSBSBS([BST][BSTF][BST])");
 }
Exemplo n.º 4
0
 public function checkCodeceptionTest(CliGuy $I)
 {
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('run order CodeTest.php --no-exit');
     $I->seeFileFound('order.txt', 'tests/_log');
     $I->expect('global bootstrap, initialization, beforeSuite, beforeClass, bootstrap, before, after, afterSuite, afterClass');
     $I->seeFileContentsEqual("BI({B[C])}");
 }
Exemplo n.º 5
0
 /**
  * @before moveToIncluded
  * @param CliGuy $I
  */
 public function runIncludedWithCoverage(\CliGuy $I)
 {
     $I->executeCommand('run --coverage-xml');
     $I->amInPath('_log');
     $I->seeFileFound('coverage.xml');
     $I->seeInThisFile('<class name="BillEvans" namespace="Jazz\\Pianist">');
     $I->seeInThisFile('<class name="Musician" namespace="Jazz">');
     $I->seeInThisFile('<class name="Hobbit" namespace="Shire">');
 }
Exemplo n.º 6
0
 /**
  * @group reports
  * @param CliGuy $I
  */
 public function runXmlReport(\CliGuy $I)
 {
     $I->wantTo('check xml reports');
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('run dummy --xml');
     $I->seeFileFound('report.xml', 'tests/_log');
     $I->seeInThisFile('<?xml');
     $I->seeInThisFile('<testsuite name="dummy"');
     $I->seeInThisFile('<testcase file="FileExistsCept.php"');
 }
Exemplo n.º 7
0
 protected function checkCompatFilesCreated(\CliGuy $I)
 {
     $I->seeDirFound('tests/_log');
     $I->seeDirFound('tests/_data');
     $I->seeDirFound('tests/_helpers');
     $I->seeFileFound('functional.suite.yml', 'tests');
     $I->seeFileFound('acceptance.suite.yml', 'tests');
     $I->seeFileFound('unit.suite.yml', 'tests');
     $I->seeFileFound('_bootstrap.php', 'tests/acceptance');
     $I->seeFileFound('_bootstrap.php', 'tests/functional');
     $I->seeFileFound('_bootstrap.php', 'tests/unit');
     $I->seeFileFound('WebGuy.php', 'tests/acceptance');
     $I->seeFileFound('TestGuy.php', 'tests/functional');
     $I->seeFileFound('CodeGuy.php', 'tests/unit');
     $I->seeFileFound('WebHelper.php', 'tests/_helpers');
     $I->seeFileFound('TestHelper.php', 'tests/_helpers');
     $I->seeFileFound('CodeHelper.php', 'tests/_helpers');
 }
    public function reRunFailedTests(CliGuy $I)
    {
        $ds = DIRECTORY_SEPARATOR;
        $I->amInPath('tests/data/sandbox');
        $I->executeCommand('run unit FailingTest.php -c codeception_extended.yml --no-exit');
        $I->seeInShellOutput('FAILURES');
        $I->seeFileFound('failed', 'tests/_output');
        $I->seeFileContentsEqual(<<<EOF
tests{$ds}unit{$ds}FailingTest.php:testMe
EOF
);
        $I->executeCommand('run -g failed -c codeception_extended.yml --no-exit');
        $I->seeInShellOutput('Tests: 1, Assertions: 1, Failures: 1');
    }
Exemplo n.º 9
0
 public function toTestCrossVolumeRename(CliGuy $I)
 {
     $fsStack = $I->taskFilesystemStack()->mkdir('log')->touch('log/error.txt');
     $fsStack->run();
     // We can't force _rename to run the cross-volume
     // code path, so we will directly call the protected
     // method crossVolumeRename to test to ensure it works.
     // We will get a reference to it via reflection, set
     // the reflected method object to public, and then
     // call it via reflection.
     $class = new ReflectionClass('\\Robo\\Task\\Filesystem\\FilesystemStack');
     $method = $class->getMethod('crossVolumeRename');
     $method->setAccessible(true);
     $actualFsStackTask = $fsStack->getCollectionBuilderCurrentTask();
     $method->invokeArgs($actualFsStackTask, ['log', 'logfiles']);
     $I->dontSeeFileFound('log/error.txt');
     $I->seeFileFound('logfiles/error.txt');
 }
Exemplo n.º 10
0
 public function generateEnvConfig(CliGuy $I)
 {
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('g:env firefox');
     $I->seeInShellOutput('firefox config was created');
     $I->seeFileFound('tests/_envs/firefox.yml');
 }
<?php

$I = new CliGuy($scenario);
$I->wantTo('generate gherkin steps');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:feature scenario Login');
$I->seeInShellOutput('Feature was created');
$I->seeFileFound('Login.feature', 'tests/scenario');
$I->seeInThisFile('Feature: Login');
$I->deleteThisFile();
$I->executeCommand('generate:feature scenario dummy/Login');
$I->seeFileFound('Login.feature', 'tests/scenario/dummy');
$I->seeInThisFile('Feature: Login');
Exemplo n.º 12
0
 public function replaceMultipleInFile(CliGuy $I)
 {
     $I->taskReplaceInFile('box/robo.txt')->from(array('HELLO', 'ROBO'))->to(array('Hello ', 'robo.li!'))->run();
     $I->seeFileFound('box/robo.txt');
     $I->seeFileContentsEqual('Hello robo.li!');
 }
Exemplo n.º 13
0
 public function checkBootstrapIsLoadedBeforeTests(CliGuy $I)
 {
     $I->amInPath('tests/data/sandbox');
     $I->executeCommand('run order ParsedLoadedTest.php');
     $I->seeFileFound('order.txt', 'tests/_output');
     $I->seeInThisFile('BIBP(T)');
 }
Exemplo n.º 14
0
<?php

$I = new CliGuy($scenario);
$I->wantToTest('build command');
$I->runShellCommmand('php codecept build');
$I->seeInShellOutput('generated sucessfully');
$I->seeFileFound('TestGuy.php', 'tests/functional');
$I->seeFileFound('CodeGuy.php', 'tests/unit');
$I->seeFileFound('CliGuy.php', 'tests/acceptance');
$I->seeInThisFile('seeFileFound(');
Exemplo n.º 15
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('flatten dir with FlattenDir task');
$I->amInPath(codecept_data_dir() . 'sandbox');
$I->taskFlattenDir(['some/deeply/nested/*.re' => 'flattened', '*.txt' => 'flattened'])->run();
$I->seeDirFound('flattened');
$I->seeFileFound('structu.re', 'flattened');
$I->seeFileFound('a.txt', 'flattened');
$I->seeFileFound('b.txt', 'flattened');
Exemplo n.º 16
0
 protected function checkFilesCreated(\CliGuy $I)
 {
     $I->seeDirFound('tests/_support');
     $I->seeDirFound('tests/_data');
     $I->seeDirFound('tests/_output');
     $I->seeDirFound('tests/_envs');
     $I->seeFileFound('functional.suite.yml', 'tests');
     $I->seeFileFound('acceptance.suite.yml', 'tests');
     $I->seeFileFound('unit.suite.yml', 'tests');
     $I->seeFileFound('_bootstrap.php', 'tests/acceptance');
     $I->seeFileFound('_bootstrap.php', 'tests/functional');
     $I->seeFileFound('_bootstrap.php', 'tests/unit');
     $I->seeFileFound('AcceptanceTester.php', 'tests/_support');
     $I->seeFileFound('FunctionalTester.php', 'tests/_support');
     $I->seeFileFound('UnitTester.php', 'tests/_support');
     $I->seeFileFound('Acceptance.php', 'tests/_support/Helper');
     $I->seeFileFound('Functional.php', 'tests/_support/Helper');
     $I->seeFileFound('Unit.php', 'tests/_support/Helper');
 }
Exemplo n.º 17
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('copy dir with CopyDir task');
$I->amInPath(codecept_data_dir() . 'sandbox');
$I->taskCopyDir(['box' => 'bin'])->run();
$I->seeDirFound('bin');
$I->seeFileFound('robo.txt', 'bin');
Exemplo n.º 18
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('copy dir recursively with CopyDir task');
$I->amInPath(codecept_data_dir() . 'sandbox');
$I->seeDirFound('some/deeply/nested');
$I->seeFileFound('structu.re', 'some/deeply/nested');
$I->taskCopyDir(['some/deeply' => 'some_destination/deeply'])->run();
$I->seeDirFound('some_destination/deeply/nested');
$I->seeFileFound('structu.re', 'some_destination/deeply/nested');
Exemplo n.º 19
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('generate sample Cept');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:cept dummy DummyCept');
$I->seeFileFound('DummyCept.php', 'tests/dummy');
$I->seeInThisFile('$I = new DumbGuy($scenario);');
$I->deleteThisFile();
$I->amGoingTo('create scenario in folder');
$I->executeCommand('generate:cept dummy path/DummyCept');
$I->seeFileFound('DummyCept.php', 'tests/dummy/path');
$I->deleteThisFile();
$I->amGoingTo('create file with Cept.php suffix');
$I->executeCommand('generate:cept dummy DummyCept.php');
$I->seeFileFound('DummyCept.php');
$I->deleteThisFile();
$I->amGoingTo('create file without any suffix');
$I->executeCommand('generate:cept dummy Dummy');
$I->seeFileFound('DummyCept.php');
Exemplo n.º 20
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('generate sample Test');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:phpunit dummy Dummy');
$I->seeFileFound('DummyTest.php');
$I->seeInThisFile('class DummyTest extends \\PHPUnit_Framework_TestCase');
$I->seeInThisFile('function setUp()');
Exemplo n.º 21
0
<?php

$I = new CliGuy($scenario);
$I->wantToTest('build command');
$I->runShellCommand('php codecept build');
$I->seeInShellOutput('generated successfully');
$I->seeFileFound('CodeGuy.php', 'tests/unit');
$I->seeFileFound('CliGuy.php', 'tests/cli');
$I->seeInThisFile('seeFileFound(');
Exemplo n.º 22
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('archive directory and then extract it again with Archive and Extract tasks');
$I->amInPath(codecept_data_dir() . 'sandbox');
$I->seeDirFound('some/deeply/nested');
$I->seeFileFound('structu.re', 'some/deeply/nested');
$I->seeFileFound('existing_file', 'some/deeply');
// Test a bunch of archive types that we support
foreach (['zip', 'tar', 'tar.gz', 'tar.bz2', 'tgz'] as $archiveType) {
    // First, take everything from the folder 'some/deeply' and make
    // an archive for it located in 'deep'
    $I->taskPack("deeply.{$archiveType}")->add(['deep' => 'some/deeply'])->run();
    $I->seeFileFound("deeply.{$archiveType}");
    // We are next going to extract the archive we created, this time
    // putting it into a folder called "extracted-$archiveType" (different
    // for each archive type we test).  We rely on the default behavior
    // of our extractor to remove the top-level directory in the archive
    // ("deeply").
    $I->taskExtract("deeply.{$archiveType}")->to("extracted-{$archiveType}")->preserveTopDirectory(false)->run();
    $I->seeDirFound("extracted-{$archiveType}");
    $I->seeDirFound("extracted-{$archiveType}/nested");
    $I->seeFileFound('structu.re', "extracted-{$archiveType}/nested");
    // Next, we'll extract the same archive again, this time preserving
    // the top-level folder.
    $I->taskExtract("deeply.{$archiveType}")->to("preserved-{$archiveType}")->preserveTopDirectory()->run();
    $I->seeDirFound("preserved-{$archiveType}");
    $I->seeDirFound("preserved-{$archiveType}/deep/nested");
    $I->seeFileFound('structu.re', "preserved-{$archiveType}/deep/nested");
    // Make another archive, this time composed of fanciful locations
    $I->taskPack("composed.{$archiveType}")->add(['a/b/existing_file' => 'some/deeply/existing_file'])->add(['x/y/z/structu.re' => 'some/deeply/nested/structu.re'])->run();
<?php

$I = new CliGuy($scenario);
$I->am('developer who likes testing');
$I->wantTo('generate sample Suite');
$I->lookForwardTo('have a better tests categorization');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:suite house HouseGuy');
$I->seeFileFound('house.suite.yml', 'tests');
$I->expect('guy class is generated');
$I->seeInThisFile('class_name: HouseGuy');
$I->seeInThisFile('- \\Helper\\House');
$I->seeFileFound('House.php', 'tests/_support/Helper');
$I->seeInThisFile('namespace Helper;');
$I->seeFileFound('_bootstrap.php', 'tests/house');
$I->expect('suite is not created due to dashes');
$I->executeCommand('generate:suite invalid-dash-suite');
$I->seeInShellOutput('contains invalid characters');
Exemplo n.º 24
0
    <?php 
$I = new CliGuy($scenario);
$I->am('developer who likes testing');
$I->wantTo('generate sample Suite');
$I->lookForwardTo('have a better tests categorization');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:suite house HouseGuy');
$I->seeFileFound('house.suite.yml', 'tests');
$I->expect('guy class is generated');
$I->seeInThisFile('class_name: HouseGuy');
$I->seeFileFound('HouseHelper.php', 'tests/_helpers');
$I->seeFileFound('_bootstrap.php', 'tests/house');
Exemplo n.º 25
0
<?php

$testsPath = __DIR__ . '/../';
$I = new CliGuy($scenario);
$I->wantTo('generate xml reports for unit tests');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run unit --xml --no-exit');
$I->seeFileFound('report.xml', 'tests/_output');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="unit"');
$I->seeInThisFile('<testcase name="testMe" class="PassingTest"');
$I->seeInThisFile('<testcase name="testIsTriangle with data set #0" class="DataProvidersTest" ' . 'file="' . realpath($testsPath . '/data/sandbox/tests/unit/DataProvidersTest.php') . '" ');
$I->seeInThisFile('<testcase name="testOne" class="DependsTest"');
$I->seeInThisFile('<failure type="PHPUnit_Framework_ExpectationFailedException">FailingTest::testMe');
Exemplo n.º 26
0
<?php
$I = new CliGuy($scenario);
$I->wantTo('generate xml reports for unit tests');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run unit --xml --no-exit');
$I->seeFileFound('report.xml','tests/_log');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="unit" tests="5" assertions="5" failures="2" errors="0"');
$I->seeInThisFile('<testcase name="testMe" class="PassingTest"');
$I->seeInThisFile('<testcase name="testIsTriangle with data set #0" assertions="1"');
$I->seeInThisFile('<testcase name="testOne" class="DependsTest"');
$I->seeInThisFile('<failure type="PHPUnit_Framework_ExpectationFailedException">test one');


Exemplo n.º 27
0
    public function runWithCustomOuptutPath(\CliGuy $I)
    {
        $I->executeCommand('run dummy --xml myverycustom.xml --html myownhtmlreport.html');
        $I->seeFileFound('myverycustom.xml', 'tests/_log');
        $I->seeInThisFile('<?xml');
        $I->seeInThisFile('<testsuite name="dummy"');
        $I->seeInThisFile('<testcase name="FileExists"');
        $I->seeFileFound('myownhtmlreport.html', 'tests/_log');
        $I->dontSeeFileFound('report.xml','tests/_log');
        $I->dontSeeFileFound('report.html','tests/_log');

    }
Exemplo n.º 28
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('change configs and check that Guy is rebuilt');
$I->amInPath('tests/data/sandbox');
$I->writeToFile('tests/unit.suite.yml', <<<EOF
class_name: CodeGuy
modules:
    enabled: [Cli, CodeHelper]
EOF
);
$I->executeCommand('run unit PassingTest.php --debug');
$I->seeInShellOutput('Cli');
$I->seeFileFound('tests/_support/_generated/CodeGuyActions.php');
$I->seeInThisFile('public function seeInShellOutput');
$I->seeInThisFile('public function runShellCommand');
<?php

$I = new CliGuy($scenario);
$I->wantTo('generate scenarios сценарий');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('generate:scenarios dummy');
$I->seeFileFound('File_Exists.txt', 'tests/_data/scenarios');
$I->seeFileContentsEqual(<<<EOF
I WANT TO CHECK CONFIG EXISTS

I see file found "codeception.yml"
EOF
);
Exemplo n.º 30
0
<?php

$I = new CliGuy($scenario);
$I->wantTo('change configs and check that Guy is rebuilt');
$I->amInPath('tests/data/sandbox');
$I->writeToFile('tests/unit.suite.yml', <<<EOF
class_name: CodeGuy
modules:
    enabled: [Cli, CodeHelper]
EOF
);
$I->executeCommand('run unit PassingTest.php --debug');
$I->seeInShellOutput('Cli');
$I->seeFileFound('tests/unit/CodeGuy.php');
$I->seeInThisFile('public function seeInShellOutput');
$I->seeInThisFile('public function runShellCommand');