public function configStartWithWrongPath(CliGuy $I) { $I->wantTo('start codeception with wrong path to a codeception.yml file'); $I->amInPath('tests/data/register_command/'); $I->executeFailCommand('-c no/exists/codeception.yml'); $I->seeInShellOutput('Your configuration file `no/exists/codeception.yml` could not be found.'); }
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])"); }
public function runOneGroup(\CliGuy $I) { $I->amInPath('tests/data/sandbox'); $I->executeCommand('run skipped -g notorun'); $I->seeInShellOutput("Incomplete"); $I->dontSeeInShellOutput("Skipped"); }
public function useTheMirrorDirShortcut(CliGuy $I) { $I->wantTo('mirror dir with _mirrorDir shortcut'); $I->shortcutMirrorDir('box', 'bin'); $I->seeDirFound('bin'); $I->seeFileFound('robo.txt', 'bin'); }
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])}'); }
public function toExecLsCommand(CliGuy $I) { $command = strncasecmp(PHP_OS, 'WIN', 3) == 0 ? 'dir' : 'ls'; $res = $I->taskExec($command)->run(); verify($res->getMessage())->contains('src'); verify($res->getMessage())->contains('codeception.yml'); }
public function checkEnvParamsPassed(CliGuy $I) { $I->amInPath('tests/data/params'); $I->executeCommand('run --no-exit'); $I->seeInShellOutput('FAILURES'); $I->seeInShellOutput("Failed asserting that an array contains 'val1'"); }
/** * @before moveToIncluded * @param CliGuy $I */ public function buildIncluded(\CliGuy $I) { $I->executeCommand('build'); $I->seeInShellOutput('generated successfully'); $I->seeInShellOutput('Jazz\\TestGuy'); $I->seeInShellOutput('Jazz\\Pianist\\TestGuy'); $I->seeInShellOutput('Shire\\TestGuy'); }
public function startMyCommandWithOptionAndConfigurationAtNewPlace(CliGuy $I) { $myname = get_current_user(); $I->amInPath('tests/data/register_command'); $I->executeCommand('myProject:myCommand --config standard/codeception.yml --friendly'); $I->seeInShellOutput("Hello {$myname},"); $I->seeInShellOutput("how are you?"); }
protected function checkAllSuitesExecuted(\CliGuy $I) { $I->seeInShellOutput('[ToastPack]'); $I->seeInShellOutput('ToastPack.unit Tests'); $I->seeInShellOutput('[EwokPack]'); $I->seeInShellOutput('EwokPack.unit Tests'); $I->seeInShellOutput('[AcmePack]'); $I->seeInShellOutput('AcmePack.unit Tests'); $I->dontSeeInShellOutput('[Spam]'); $I->dontSeeInShellOutput('[SpamPack]'); }
public function runFeature(CliGuy $I) { $I->executeCommand('dry-run scenario File.feature --no-ansi'); $I->seeInShellOutput('Run gherkin: Check file exists'); $I->seeInShellOutput('In order to test a feature'); $I->seeInShellOutput('As a user'); $I->seeInShellOutput('Given i have terminal opened'); $I->seeInShellOutput('INCOMPLETE'); $I->seeInShellOutput('Step definition for `I have only idea of what\'s going on here` not found'); }
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'); }
/** * @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">'); }
public function snippetsScenarioFolder(CliGuy $I) { $I->executeCommand('gherkin:snippets scenario subfolder'); $I->seeInShellOutput('Given I have a feature in a subfolder'); $I->seeInShellOutput('public function iHaveAFeatureInASubfolder'); $I->dontSeeInShellOutput('@Given I have only idea of what\'s going on here'); $I->dontSeeInShellOutput('public function iHaveOnlyIdeaOfWhatsGoingOnHere'); }
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])}"); }
public function environmentsFromSubfolders(CliGuy $I) { $I->amInPath('tests/data/sandbox'); $I->executeCommand('run messages MessageCest.php:allMessages -vv --env env3'); $I->seeInShellOutput('MESSAGE2 FROM ENV3'); }
<?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');
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!'); }
<?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->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(');
<?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');
<?php $I = new CliGuy($scenario); $I->wantTo('see that comments can be easily added to test'); $I->amInPath('tests/data/sandbox'); $I->executeCommand('run tests/skipped/CommentsCept.php --steps'); $I->seeInShellOutput('* As a very lazy qa'); $I->seeInShellOutput('* So that I not do anything at all'); $I->seeInShellOutput('* have a comment for you'); $I->seeInShellOutput('* but I am too lazy to do any job'); $I->seeInShellOutput('* so please do that yourself'); $I->seeInShellOutput('I am going to leave that to you'); $I->seeInShellOutput('I expect you forgive me');
<?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');
<?php $I = new CliGuy($scenario); $I->wantTo('execute incomplete test'); $I->amInPath('tests/data/sandbox'); $I->executeCommand('run skipped IncompleteMeCept.php'); $I->seeInShellOutput("I IncompleteMeCept: Make it incomplete"); $I->seeInShellOutput('OK, but incomplete, skipped, or risky tests!');
<?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');
/** * @before skipIfNoXdebug * @param CliGuy $I */ public function runTestWithSubSteps(\CliGuy $I) { $file = "codeception" . DIRECTORY_SEPARATOR . "c3"; $I->executeCommand('run scenario SubStepsCept --steps'); $I->seeInShellOutput(<<<EOF Scenario: * I am in path "." * I see code coverage files are present I see file found "c3.php" I see file found "composer.json" I see in this file "{$file}" EOF ); }
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'); }
<?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');
public function runTestWithDataProviders(\CliGuy $I) { $I->amInPath('tests/data/sandbox'); $I->executeCommand('run tests/unit/DataProvidersTest.php'); $I->seeInShellOutput('Trying to test is triangle with data set "real triangle" (DataProvidersTest::testIsTriangle)'); $I->seeInShellOutput('Trying to test is triangle with data set #0 (DataProvidersTest::testIsTriangle)'); $I->seeInShellOutput('Trying to test is triangle with data set #1 (DataProvidersTest::testIsTriangle)'); $I->seeInShellOutput("OK"); }
<?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');