コード例 #1
0
ファイル: FrontendCest.php プロジェクト: d-m-/bolt
 /**
  * Check the contact page for templatefields
  *
  * @param \AcceptanceTester $I
  */
 public function checkContactPageTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo('see that the contact page and templatefields works');
     $scenario->skip('Update Required');
     $I->amOnPage('/contact');
     $I->seeInSource('This is the contact text');
 }
コード例 #2
0
ファイル: Console.php プロジェクト: Eli-TW/Codeception
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suiteName = $input->getArgument('suite');
     $this->output = $output;
     $config = Configuration::config($input->getOption('config'));
     $settings = Configuration::suiteSettings($suiteName, $config);
     $options = $input->getOptions();
     $options['debug'] = true;
     $options['steps'] = true;
     $this->codecept = new Codecept($options);
     $dispatcher = $this->codecept->getDispatcher();
     $this->test = (new Cept())->configDispatcher($dispatcher)->configName('interactive')->config('file', 'interactive')->initConfig();
     $suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
     $suiteManager->initialize();
     $this->suite = $suiteManager->getSuite();
     $scenario = new Scenario($this->test);
     $actor = $settings['class_name'];
     $I = new $actor($scenario);
     $this->listenToSignals();
     $output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
     $output->writeln("<info>Try Codeception commands without writing a test</info>");
     $output->writeln("<info>type 'exit' to leave console</info>");
     $output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
     $suiteEvent = new SuiteEvent($this->suite, $this->codecept->getResult(), $settings);
     $dispatcher->dispatch(Events::SUITE_BEFORE, $suiteEvent);
     $dispatcher->dispatch(Events::TEST_PARSED, new TestEvent($this->test));
     $dispatcher->dispatch(Events::TEST_BEFORE, new TestEvent($this->test));
     $output->writeln("\n\n\$I = new {$settings['class_name']}(\$scenario);");
     $scenario->run();
     $this->executeCommands($output, $I, $settings['bootstrap']);
     $dispatcher->dispatch(Events::TEST_AFTER, new TestEvent($this->test));
     $dispatcher->dispatch(Events::SUITE_AFTER, new SuiteEvent($this->suite));
     $output->writeln("<info>Bye-bye!</info>");
 }
コード例 #3
0
ファイル: Console.php プロジェクト: lenninsanchez/donadores
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $suiteName = $input->getArgument('suite');
     $this->output = $output;
     $config = \Codeception\Configuration::config($input->getOption('config'));
     $settings = \Codeception\Configuration::suiteSettings($suiteName, $config);
     $options = $input->getOptions();
     $options['debug'] = true;
     $options['steps'] = true;
     $this->codecept = new \Codeception\Codecept($options);
     $dispatcher = $this->codecept->getDispatcher();
     $suiteManager = new SuiteManager($dispatcher, $suiteName, $settings);
     $this->suite = $suiteManager->getSuite();
     $this->test = new Cept($dispatcher, array('name' => 'interactive', 'file' => 'interactive'));
     $guy = $settings['class_name'];
     $scenario = new Scenario($this->test);
     $I = new $guy($scenario);
     $this->listenToSignals();
     $output->writeln("<info>Interactive console started for suite {$suiteName}</info>");
     $output->writeln("<info>Try Codeception commands without writing a test</info>");
     $output->writeln("<info>type 'exit' to leave console</info>");
     $output->writeln("<info>type 'actions' to see all available actions for this suite</info>");
     $dispatcher->dispatch('suite.before', new Suite($this->suite, $this->codecept->getResult(), $settings));
     $dispatcher->dispatch('test.parsed', new \Codeception\Event\Test($this->test));
     $dispatcher->dispatch('test.before', new \Codeception\Event\Test($this->test));
     $output->writeln("\n\n\$I = new {$settings['class_name']}(\$scenario);");
     $scenario->run();
     $this->executeCommands($output, $I, $settings['bootstrap']);
     $dispatcher->dispatch('test.after', new \Codeception\Event\Test($this->test));
     $dispatcher->dispatch('suite.after', new Suite($this->suite));
     $output->writeln("<info>Bye-bye!</info>");
 }
コード例 #4
0
ファイル: LogstashCest.php プロジェクト: index0h/yii2-log
 public function addWrongLogstashLog(\CodeGuy $I, \Codeception\Scenario $scenario)
 {
     if ($scenario->running() === false) {
         return;
     }
     $I->removeEmergencyLog();
     $I->addWrongLogstashLog('WrongLogstashLog');
     $I->seeEmergencyLog('WrongLogstashLog');
 }
コード例 #5
0
ファイル: LogstashFileCest.php プロジェクト: index0h/yii2-log
 public function addLogstashLogToFile(\CodeGuy $I, \Codeception\Scenario $scenario)
 {
     if ($scenario->running() === false) {
         return;
     }
     $I->removeLogstashFile();
     $I->addLogstashFileLog('logstashFileLog_array', 'array');
     $I->addLogstashFileLog('logstashFileLog_stdClass', 'stdClass');
     $I->seeLogstashFile();
 }
コード例 #6
0
ファイル: AbstractGuy.php プロジェクト: BatVane/Codeception
 public function __call($method, $args)
 {
     // if (!in_array($method, array_keys(TestGuy::$methods))) throw new \RuntimeException("Action $method not defined");
     if (0 === strpos($method, 'see')) {
         $this->scenario->assertion(array_merge(array($method), $args));
     } elseif (0 === strpos($method, 'am')) {
         $this->scenario->condition(array_merge(array($method), $args));
     } else {
         $this->scenario->action(array_merge(array($method), $args));
     }
     return $this;
 }
コード例 #7
0
ファイル: Gherkin.php プロジェクト: neronmoon/Codeception
 protected function runStep(StepNode $stepNode)
 {
     $params = [];
     if ($stepNode->hasArguments()) {
         $args = $stepNode->getArguments();
         $table = $args[0];
         if ($table instanceof TableNode) {
             $params = [$table->getTableAsString()];
         }
     }
     $meta = new Meta($stepNode->getText(), $params);
     $meta->setPrefix($stepNode->getKeyword());
     $this->scenario->setMetaStep($meta);
     // enable metastep
     $stepText = $stepNode->getText();
     $this->getScenario()->comment(null);
     // make metastep to be printed even if no steps
     foreach ($this->steps as $pattern => $context) {
         $matches = [];
         if (!preg_match($pattern, $stepText, $matches)) {
             continue;
         }
         array_shift($matches);
         if ($stepNode->hasArguments()) {
             $matches = array_merge($matches, $stepNode->getArguments());
         }
         call_user_func_array($context, $matches);
         // execute the step
         break;
     }
     $this->scenario->setMetaStep(null);
     // disable metastep
 }
コード例 #8
0
 public function __call($method, $arguments)
 {
     if ($this->scenario->running()) {
         $class = get_class($this);
         throw new \RuntimeException("Call to undefined method {$class}::{$method}");
     }
     $this->scenario->addStep(new Action($method, $arguments));
 }
コード例 #9
0
ファイル: CodeSnifferCest.php プロジェクト: GreenCape/robo
 /**
  * @param \CliTester            $I
  * @param \Codeception\Scenario $scenario
  */
 public function testDocumentValidHtml(\CliTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo('verify that the default template produces valid HTML');
     if (!class_exists('Tidy')) {
         $scenario->skip('Tidy is not available. See http://php.net/manual/en/tidy.installation.php');
     }
     $template = dirname(dirname(__DIR__)) . '/src/Task/CodeSniffer/codestyle.html';
     $outfile = dirname(__DIR__) . '/_output/codestyle.html';
     if (file_exists($outfile)) {
         unlink($outfile);
     }
     $I->dontSeeFileFound($outfile);
     $I->runShellCommand('vendor/bin/robo document:codestyle --outfile ' . $outfile . ' --template ' . $template);
     $I->seeFileFound($outfile);
     $tidy = new \Tidy();
     $tidy->parseFile($outfile);
     $I->assertEquals(0, $tidy->getStatus());
     unlink($outfile);
 }
コード例 #10
0
ファイル: ParserTest.php プロジェクト: foxman209/Codeception
 public function testStepsWithFriends()
 {
     $code = file_get_contents(\Codeception\Configuration::projectDir() . 'tests/web/FriendsCept.php');
     $this->assertContains('$I->haveFriend', $code);
     $this->parser->parseSteps($code);
     $text = $this->scenario->getText();
     $this->assertContains("jon does", $text);
     $this->assertContains("I have friend", $text);
     $this->assertContains("back to me", $text);
 }
コード例 #11
0
 /**
  * @depends checkThatBookmarkListIsInitiallyEmpty
  * @param Admin $I
  * @param ModalDialog $dialog
  * @return Admin
  */
 public function checkThatAddingABookmarkAddsItemToTheBookmarkList(Admin $I, ModalDialog $dialog, Scenario $scenario)
 {
     $I->switchToIFrame();
     // open the scheduler module as we would like to put it into the bookmark liste
     $I->click('Scheduler', '#typo3-module-menu');
     $I->switchToIFrame('content');
     $I->click(self::$docHeaderBookmarkButtonSelector);
     // cancel the action to test the functionality
     $dialog->clickButtonInDialog('Cancel');
     // check if the list is still empty
     $this->checkThatBookmarkListIsInitiallyEmpty($I);
     $I->switchToIFrame('content');
     $I->click(self::$docHeaderBookmarkButtonSelector);
     $dialog->clickButtonInDialog('OK');
     $this->clickBookmarkDropdownToggleInTopbar($I);
     $I->waitForText('Scheduled tasks', 15, self::$topBarModuleSelector . ' ' . Topbar::$dropdownContainerSelector);
     // @test complete test when https://forge.typo3.org/issues/75689 is fixed
     $scenario->comment('Tests for deleting the item in the list and readding it are missing ' . 'as this is currently broken in the core. See https://forge.typo3.org/issues/75689');
     return $I;
 }
コード例 #12
0
ファイル: BackendManagerCest.php プロジェクト: d-m-/bolt
 /**
  * Publish the 'Contact' page.
  *
  * @param \AcceptanceTester $I
  */
 public function publishContactPageTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo("Publish the 'Contact' page with 'templatefields' as 'manager' user");
     $scenario->skip('Update Required');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt/editcontent/pages/3');
     $I->seeInSource('This is the contact text');
     $I->selectOption('#statusselect', 'published');
     $I->click('Save', '#savecontinuebutton');
     $I->see('The changes to the Page have been saved.');
 }
コード例 #13
0
ファイル: Parser.php プロジェクト: solutionDrive/Codeception
 protected function addCommentStep($comment)
 {
     $this->scenario->addStep(new \Codeception\Step\Comment($comment, []));
 }
コード例 #14
0
ファイル: BackendDeveloperCest.php プロジェクト: d-m-/bolt
 /**
  * Test that the 'developer' user can configure installed extensions.
  *
  * @param \AcceptanceTester $I
  */
 public function configureInstalledExtensions(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo("See that the 'developer' user can configure installed extensions.");
     $scenario->skip('Update Required');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt/files/config/extensions');
     $I->see('tester-events.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/tester-events.bolt.yml'));
     $I->click('tester-events.bolt.yml', Locator::href('/bolt/file/edit/config/extensions/tester-events.bolt.yml'));
     $I->see('# Sit back and breathe', 'textarea');
     $I->see('its_nice_to_know_you_work_alone: true', 'textarea');
     // Edit the field
     $twig = $I->grabTextFrom('#form_contents', 'textarea');
     $twig .= PHP_EOL . "# Let's make this perfectly clear";
     $twig .= PHP_EOL . 'theres_no_secrets_this_year: true' . PHP_EOL;
     $I->fillField('#form_contents', $twig);
     $token = $I->grabValueFrom('#form__token');
     $I->sendAjaxPostRequest('/bolt/file/edit/config/extensions/tester-events.bolt.yml', ['form[_token]' => $token, 'form[contents]' => $twig]);
     $I->amOnPage('/bolt/file/edit/config/extensions/tester-events.bolt.yml');
     $I->see("# Let's make this perfectly clear", 'textarea');
     $I->see('theres_no_secrets_this_year: true', 'textarea');
 }
コード例 #15
0
ファイル: Actor.php プロジェクト: hitechdk/Codeception
 /**
  * Lazy-execution given anonymous function
  * @param $callable \Closure
  * @return $this
  */
 public function execute($callable)
 {
     $this->scenario->addStep(new Executor($callable, []));
     $callable();
     return $this;
 }
コード例 #16
0
ファイル: RunCest.php プロジェクト: corcre/elabftw
 protected function skipIfNoXdebug($I, \Codeception\Scenario $s)
 {
     if (!extension_loaded('xdebug')) {
         $s->skip("Xdebug not loaded");
     }
 }
コード例 #17
0
ファイル: BackendEditorCest.php プロジェクト: d-m-/bolt
 /**
  * Create a contact page with templatefields
  *
  * @param \AcceptanceTester $I
  */
 public function checkTemplateFieldsTest(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo('Create a contact page with templatefields');
     $scenario->skip('Update Required');
     // Set up the browser
     $I->setCookie($this->tokenNames['authtoken'], $this->cookies[$this->tokenNames['authtoken']]);
     $I->setCookie($this->tokenNames['session'], $this->cookies[$this->tokenNames['session']]);
     $I->amOnPage('/bolt');
     $I->see('New Page');
     $I->click('New Page');
     $I->fillField('#title', 'Contact Page');
     $I->fillField('#slug', 'contact');
     $I->selectOption('#template', 'extrafields.twig');
     $I->click('Save Page', '#savecontinuebutton');
     $I->see('The new Page has been saved.');
     $I->click('CONTACT PAGE');
     // Page has been saved, fill templatefields
     $I->see('Template', 'a[data-toggle=tab]');
     $I->fillField('#templatefields-section_1', 'This is the contact text');
     $I->click('Save Page');
     $I->click('CONTACT PAGE');
     /*
      * In v2.0.13 Codeception made the awesome decision to refactor their
      * PHP Browser code — in a patch release no less — and it doesn't
      * properly handle URL queries parameters in POSTs. For now we'll just
      * pretend that seeing the data is good enough…
      */
     $I->seeInSource('This is the contact text');
     //         $I->seeInField('#templatefields-section_1', 'This is the contact text');
 }
コード例 #18
0
 /**
  * get failing step from a scenario
  *
  * @param $scenario
  * @return Step
  */
 protected function getFailingStep(Scenario $scenario)
 {
     // failed step is last step with executed = true
     $steps = $scenario->getSteps();
     foreach ($steps as $step) {
         /** @var $step Step */
         if ($step->executed == false) {
             return $step;
         }
     }
     return current(array_reverse($steps));
 }
コード例 #19
0
ファイル: Actor.php プロジェクト: itillawarra/cmfive
 /**
  * Lazy-execution given anonymous function
  * @param $callable \Closure
  * @return $this
  */
 public function execute($callable)
 {
     $this->scenario->addStep(new \Codeception\Step\Executor($callable, array()));
     $callable();
     return $this;
 }
コード例 #20
0
 /**
  * ATTENTION 後続のテストが失敗するため、最後に実行する必要がある
  */
 public function systeminfo_セキュリティ管理IP制限(\AcceptanceTester $I, \Codeception\Scenario $scenario)
 {
     $I->wantTo('EA0804-UC01-T03 セキュリティ管理 - IP制限');
     $findPlugins = Fixtures::get('findPlugins');
     $Plugins = $findPlugins();
     if (is_array($Plugins) && count($Plugins) > 0) {
         $scenario->skip('プラグインのアンインストールが必要なため、テストをスキップします');
     }
     // 表示
     $config = Fixtures::get('config');
     $I->amOnPage('/' . $config['admin_route'] . '/setting/system/security');
     $I->see('システム設定セキュリティ管理', '#main .page-header');
     $I->fillField(['id' => 'admin_security_admin_allow_host'], '1.1.1.1');
     $I->click('#aside_column div div div div div button');
     $I->amOnPage('/' . $config['admin_route']);
     $I->see('アクセスできません。', '#main .container-fluid h1');
     $test_config = Fixtures::get('test_config');
     $eccube = $test_config['eccube_path'];
     $configfile = $eccube . "/app/config/eccube/config.yml";
     $lines = file($configfile);
     $fh = fopen($configfile, 'w');
     foreach ($lines as $line) {
         if (preg_match('/1\\.1\\.1\\.1/', $line)) {
             continue;
         }
         fwrite($fh, $line);
     }
     fclose($fh);
 }
コード例 #21
0
ファイル: Actor.php プロジェクト: itillawarra/cmfive
 public function getFeature()
 {
     return $this->scenario->getFeature();
 }