/**
  * Take screenshot when step fails.
  * Works only with Selenium2Driver.
  *
  * @AfterStep
  */
 public function takeScreenshotAfterFailedStep(AfterStepScope $event)
 {
     if (0 !== $event->getTestResult()->getResultCode()) {
         $driver = $this->getSession()->getDriver();
         if (!$driver instanceof Selenium2Driver) {
             //throw new UnsupportedDriverActionException('Taking screenshots is not supported by %s, use Selenium2Driver instead.', $driver);
             return;
         }
         $screenshot = $this->getSession()->getDriver()->getScreenshot();
         $lineNumber = $event->getStep()->getLine();
         list($feature, $extension) = explode('.', substr($event->getFeature()->getFile(), strrpos($event->getFeature()->getFile(), '/') + 1));
         file_put_contents('tests/acceptance/_logs/screenshots/' . $feature . '-line-' . $lineNumber . '-failure.png', $screenshot);
     }
 }
 /**
  * take current page screenshot and save it to path
  *
  * @AfterStep
  *
  * @param  AfterStepScope $scope afterStep scope object
  *
  * @return null
  */
 public function takeScreenshot(AfterStepScope $scope)
 {
     $featureFilePath = $scope->getFeature()->getFile();
     $stepLineNumber = $scope->getStep()->getLine();
     $screenshotPath = $this->createScreenshotFilePath($featureFilePath, $stepLineNumber);
     $driver = $this->getSession()->getDriver();
     $imageData = $driver->getScreenshot();
     file_put_contents($screenshotPath, $imageData);
 }
Beispiel #3
0
 /**
  * @param AfterStepScope $scope
  * @return \Behat\Gherkin\Node\ScenarioInterface|null
  */
 private function getScenario(AfterStepScope $scope)
 {
     $scenarios = $scope->getFeature()->getScenarios();
     $stepLine = $scope->getStep()->getLine();
     $scenario = null;
     foreach ($scenarios as $scenarioTmp) {
         if ($scenarioTmp->getLine() < $stepLine) {
             $scenario = $scenarioTmp;
         }
     }
     return $scenario;
 }
Beispiel #4
0
 /**
  * @param AfterStepScope $scope
  * @return \Behat\Gherkin\Node\ScenarioInterface
  */
 private function getScenario(AfterStepScope $scope)
 {
     $scenarios = $scope->getFeature()->getScenarios();
     foreach ($scenarios as $scenario) {
         $stepLinesInScenario = array_map(function (StepNode $step) {
             return $step->getLine();
         }, $scenario->getSteps());
         if (in_array($scope->getStep()->getLine(), $stepLinesInScenario)) {
             return $scenario;
         }
     }
     throw new \LogicException('Unable to find the scenario');
 }
Beispiel #5
0
 /**
  * @param AfterStepScope $scope
  * @return \Behat\Gherkin\Node\BackgroundNode
  */
 private function getBackground(AfterStepScope $scope)
 {
     $background = $scope->getFeature()->getBackground();
     if (!$background) {
         return false;
     }
     $stepLinesInBackground = array_map(function (StepNode $step) {
         return $step->getLine();
     }, $background->getSteps());
     if (in_array($scope->getStep()->getLine(), $stepLinesInBackground)) {
         return $background;
     }
     return false;
 }
Beispiel #6
0
 /**
  * Determine the full pathname to store a failure-related dump.
  *
  * This is used for content such as the DOM, and screenshots.
  *
  * @param AfterStepScope $scope scope passed by event after step.
  * @param String $filetype The file suffix to use. Limited to 4 chars.
  */
 protected function get_faildump_filename(AfterStepScope $scope, $filetype)
 {
     global $CFG;
     // All the contentdumps should be in the same parent dir.
     if (!($faildumpdir = self::get_run_faildump_dir())) {
         $faildumpdir = self::$faildumpdirname = date('Ymd_His');
         $dir = $CFG->behat_faildump_path . DIRECTORY_SEPARATOR . $faildumpdir;
         if (!is_dir($dir) && !mkdir($dir, $CFG->directorypermissions, true)) {
             // It shouldn't, we already checked that the directory is writable.
             throw new Exception('No directories can be created inside $CFG->behat_faildump_path, check the directory permissions.');
         }
     } else {
         // We will always need to know the full path.
         $dir = $CFG->behat_faildump_path . DIRECTORY_SEPARATOR . $faildumpdir;
     }
     // The scenario title + the failed step text.
     // We want a i-am-the-scenario-title_i-am-the-failed-step.$filetype format.
     $filename = $scope->getFeature()->getTitle() . '_' . $scope->getStep()->getText();
     $filename = preg_replace('/([^a-zA-Z0-9\\_]+)/', '-', $filename);
     // File name limited to 255 characters. Leaving 5 chars for line number and 4 chars for the file.
     // extension as we allow .png for images and .html for DOM contents.
     $filename = substr($filename, 0, 245) . '_' . $scope->getStep()->getLine() . '.' . $filetype;
     return array($dir, $filename);
 }
 protected function lookForJSErrors(AfterStepScope $scope)
 {
     $current_url = $this->getSession()->getCurrentUrl();
     if (!$current_url) {
         return;
     }
     $driver = $this->getMink()->getSession()->getDriver();
     if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) {
         $html = $this->getSession()->getPage()->getHtml();
         if (false === strpos($html, 'window.jsErrors')) {
             echo "\n\n JS error detection wont work without this JS in place:\n\n<script>\n    window.jsErrors = [];\n    window.onerror = function (errorMessage) {\n        window.jsErrors[window.jsErrors.length] = errorMessage;\n    };\n</script>\n\n                ";
         } else {
             try {
                 $errors = $driver->evaluateScript("return window.jsErrors");
             } catch (\Exception $e) {
                 // output where the error occurred for debugging purposes
                 echo $this->scenarioData;
                 throw $e;
             }
             if (!$errors || empty($errors)) {
                 return;
             }
             $file = sprintf("%s:%d", $scope->getFeature()->getFile(), $scope->getStep()->getLine());
             $message = sprintf("Found %d javascript error%s", count($errors), count($errors) > 0 ? 's' : '');
             echo '-------------------------------------------------------------' . PHP_EOL;
             echo $file . PHP_EOL;
             echo $message . PHP_EOL;
             echo '-------------------------------------------------------------' . PHP_EOL;
             foreach ($errors as $index => $error) {
                 echo sprintf("   #%d: %s", $index, $error) . PHP_EOL;
             }
             throw new \Exception($message);
         }
     }
 }
 /**
  * @AfterStep
  *
  * Take screenshot and HTML dump when test fails.
  */
 public function captureScreenAfterFailedStep(AfterStepScope $scope)
 {
     if (self::ERROR_CODE !== $scope->getTestResult()->getResultCode()) {
         return;
     }
     // Remove quotes from the test step name.
     $failed_test_step = preg_replace('/[^a-zA-Z0-9\\-]+/', '_', $scope->getStep()->getText());
     // Set the screenshot location.
     $featureFolder = str_replace(' ', '', $scope->getFeature()->getTitle());
     $filePath = $this->parameters['screenshot_path'] . '/' . $featureFolder;
     if (!file_exists($filePath)) {
         mkdir($filePath);
     }
     $driver = $this->getSession()->getDriver();
     $filename_prefix = date(self::DATE_FORMAT_CONCISE) . '-' . $failed_test_step;
     if ($driver instanceof \Behat\Mink\Driver\BrowserKitDriver) {
         //  Generate HTML dump.
         $html_data = $this->getSession()->getDriver()->getContent();
         $fileName = $filename_prefix . self::EXTENSION_DOT . self::EXTENSION_HTML;
         file_put_contents($filePath . '/' . $fileName, $html_data);
     } elseif ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) {
         //  Generate HTML dump.
         $html_data = $this->getSession()->getDriver()->getContent();
         $fileName = $filename_prefix . self::EXTENSION_DOT . self::EXTENSION_HTML;
         file_put_contents($filePath . '/' . $fileName, $html_data);
         //  Generate JPG.
         $fileName = $filename_prefix . self::EXTENSION_DOT . self::EXTENSION_JPG;
         $this->saveScreenshot($fileName, $filePath);
     }
 }
 /**
  * Check for PHP errors log.
  *
  * @param AfterStepScope $scope
  *    AfterStep hook scope object.
  *
  * @throws \Exception
  *    Print out descriptive error message by throwing an exception.
  *
  * @AfterStep
  */
 public static function checkPhpErrors(AfterStepScope $scope)
 {
     // Find any PHP errors at the end of the suite
     // and output them as an exception.
     $log = db_select('watchdog', 'w')->fields('w')->condition('w.type', 'php', '=')->execute()->fetchAll();
     if (!empty($log)) {
         $errors = count($log);
         $step_text = $scope->getStep()->getText();
         $step_line = $scope->getStep()->getLine();
         $feature_title = $scope->getFeature()->getTitle();
         $feature_file = $scope->getFeature()->getFile();
         $message = "{$errors} PHP errors were logged to the watchdog\n";
         $message .= "Feature: '{$feature_title}' on '{$feature_file}' line {$step_line}\n";
         $message .= "Step: '{$step_text}'\n";
         $message .= "Errors:\n";
         $message .= "----------\n";
         foreach ($log as $error) {
             $error->variables = unserialize($error->variables);
             $date = date('Y-m-d H:i:sP', $error->timestamp);
             $message .= sprintf("Message: %s: %s in %s (line %s of %s).\n", $error->variables['%type'], $error->variables['!message'], $error->variables['%function'], $error->variables['%line'], $error->variables['%file']);
             $message .= "Location: {$error->location}\n";
             $message .= "Referer: {$error->referer}\n";
             $message .= "Date/Time: {$date}\n\n";
         }
         $message .= "----------\n";
         throw new \Exception($message);
     }
 }
 /**
  * @AfterStep
  *
  * Take screenshot when step fails.
  */
 public function takeScreenshotAfterFailedStep(AfterStepScope $scope)
 {
     if (self::ERROR_CODE === $scope->getTestResult()->getResultCode()) {
         $driver = $this->getSession()->getDriver();
         // Get the name of the feature file.
         $featureFolder = str_replace(' ', '', $scope->getFeature()->getTitle());
         // Get the name of the failed test.
         $scenarioName = $this->currentScenario->getTitle();
         $failedTest = str_replace(' ', '', $scenarioName);
         // Set the screenshot folder.
         $filePath = $this->parameters['screenshot_path'] . '/' . $featureFolder;
         if (!file_exists($filePath)) {
             mkdir($filePath);
         }
         if ($driver instanceof \Behat\Mink\Driver\BrowserKitDriver) {
             $html_data = $this->getSession()->getDriver()->getContent();
             $fileName = date(self::DATE_FORMAT_CONCISE) . '-' . $failedTest . '.html';
             file_put_contents($filePath . '/' . $fileName, $html_data);
             return;
         }
         if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) {
             $fileName = date(self::DATE_FORMAT_CONCISE) . '-' . $failedTest . '.jpg';
             $this->saveScreenshot($fileName, $filePath);
             return;
         }
     }
 }
Beispiel #11
0
 /**
  * @AfterStep
  *
  * @param AfterStepScope $scope
  */
 public function theSystemShouldNotHaveAnyOtherChange(AfterStepScope $scope)
 {
     $isLastStep = false;
     $scenarios = $scope->getFeature()->getScenarios();
     foreach ($scenarios as $scenario) {
         $count = count($scenario->getSteps());
         foreach ($scenario->getSteps() as $key => $step) {
             if ($scope->getStep() == $step) {
                 if ($key == $count - 1) {
                     $isLastStep = true;
                     break 2;
                 }
             }
         }
     }
     if (!$isLastStep) {
         return;
     }
     if (isset($this->states['Cubalider\\Sms\\Message'])) {
         /** @var CollectInfosTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('cubalider.sms.collect_messages_test_worker');
         try {
             Assert::assertEquals($this->states['Cubalider\\Sms\\Message'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Cubalider\\Sms\\Message');
         }
     }
     if (isset($this->states['Cubalider\\Uniqueness'])) {
         /** @var CollectUniquenessTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('cubalider.unique.collect_uniqueness_test_worker');
         try {
             Assert::assertEquals($this->states['Cubalider\\Uniqueness'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Cubalider\\Uniqueness');
         }
     }
     if (isset($this->states['Muchacuba\\Authentication\\Profile'])) {
         /** @var CollectAuthenticationProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.authentication.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Authentication\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Authentication\\Profile');
         }
     }
     if (isset($this->states['Cubalider\\Uniqueness'])) {
         /** @var CollectUniquenessTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('cubalider.unique.collect_uniqueness_test_worker');
         try {
             Assert::assertEquals($this->states['Cubalider\\Uniqueness'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Cubalider\\Uniqueness');
         }
     }
     if (isset($this->states['Muchacuba\\Credit\\Profile'])) {
         /** @var CollectCreditProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.credit.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Credit\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Credit\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\Credit\\Profile\\Balance\\Operation'])) {
         /** @var CollectCreditProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.credit.profile.balance.collect_operations_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Credit\\Profile\\Balance\\Operation'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Credit\\Profile\\Balance\\Operation');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Info'])) {
         /** @var CollectInfosTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_infos_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Info'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Info');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Message\\Link'])) {
         /** @var CollectMessageLinksTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.message.collect_links_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Message\\Link'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Message\\Link');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Message\\Stat'])) {
         /** @var CollectLatestMessageStatsApiWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.message.collect_latest_stats_api_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Message\\Stat'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Message\\Stat');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Package'])) {
         /** @var CollectPackagesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_packages_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Package'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Package');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Profile'])) {
         /** @var CollectInfoSmsProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\ResellPackage'])) {
         /** @var CollectResellPackagesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_resell_packages_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\ResellPackage'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\ResellPackage');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Subscription'])) {
         /** @var CollectSubscriptionsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_subscriptions_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Subscription'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Subscription');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Subscription\\LowBalanceReminder\\Log'])) {
         /** @var CollectSubscriptionLowBalanceReminderLogsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.subscription.low_balance_reminder.collect_logs_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Subscription\\LowBalanceReminder\\Log'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Subscription\\LowBalanceReminder\\Log');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Subscription\\Operation'])) {
         /** @var CollectSubscriptionOperationsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.subscription.collect_operations_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Subscription\\Operation'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Subscription\\Operation');
         }
     }
     if (isset($this->states['Muchacuba\\InfoSms\\Topic'])) {
         /** @var CollectTopicsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.info_sms.collect_topics_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\InfoSms\\Topic'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\InfoSms\\Topic');
         }
     }
     if (isset($this->states['Muchacuba\\Internet\\Profile'])) {
         /** @var CollectInternetProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.internet.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Internet\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Internet\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\Invitation\\Card'])) {
         /** @var CollectInvitationCardsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.invitation.collect_cards_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Invitation\\Card'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Invitation\\Card');
         }
     }
     if (isset($this->states['Muchacuba\\Invitation\\AssignedCard'])) {
         /** @var CollectInvitationCardsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.invitation.collect_assigned_cards_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Invitation\\AssignedCard'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Invitation\\AssignedCard');
         }
     }
     if (isset($this->states['Muchacuba\\Mobile\\Profile'])) {
         /** @var CollectMobileProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.mobile.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Mobile\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Mobile\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\Privilege\\AssignedRoles'])) {
         /** @var CollectAssignedRolesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.privilege.collect_assigned_roles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Privilege\\AssignedRoles'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Privilege\\AssignedRoles');
         }
     }
     if (isset($this->states['Muchacuba\\Internet\\Profile'])) {
         /** @var CollectInternetProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.internet.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Internet\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Internet\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\Mobile\\Profile'])) {
         /** @var CollectMobileProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.mobile.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Mobile\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Mobile\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\Privilege\\AssignedRoles'])) {
         /** @var CollectAssignedRolesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.privilege.collect_assigned_roles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\Privilege\\AssignedRoles'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\Privilege\\AssignedRoles');
         }
     }
     if (isset($this->states['Muchacuba\\RechargeCard\\Package'])) {
         /** @var CollectPackagesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.collect_packages_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\RechargeCard\\Package'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\RechargeCard\\Package');
         }
     }
     if (isset($this->states['Muchacuba\\RechargeCard\\Category'])) {
         /** @var CollectCategoriesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.collect_categories_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\RechargeCard\\Category'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\RechargeCard\\Category');
         }
     }
     if (isset($this->states['Muchacuba\\RechargeCard\\Card'])) {
         /** @var CollectCardsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.collect_cards_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\RechargeCard\\Card'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\RechargeCard\\Card');
         }
     }
     if (isset($this->states['Muchacuba\\RechargeCard\\Profile'])) {
         /** @var CollectProfilesTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.collect_profiles_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\RechargeCard\\Profile'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\RechargeCard\\Profile');
         }
     }
     if (isset($this->states['Muchacuba\\RechargeCard\\Profile\\Debt\\Operation'])) {
         /** @var CollectRechargeCardProfileDebtOperationsTestWorker $collectWorker */
         $collectWorker = $this->kernel->getContainer()->get('muchacuba.recharge_card.profile.debt.collect_operations_test_worker');
         try {
             Assert::assertEquals($this->states['Muchacuba\\RechargeCard\\Profile\\Debt\\Operation'], iterator_to_array($collectWorker->collect()));
         } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
             $this->throwException($e, 'Muchacuba\\RechargeCard\\Profile\\Debt\\Operation');
         }
     }
 }
Beispiel #12
0
 private function buildScreenshotFilename(Behat\Behat\Hook\Scope\AfterStepScope $scope)
 {
     $scenarioTitle = str_replace(array(' ', ','), '-', $scope->getFeature()->getTitle());
     return $this->screenshot_path . '/' . $scenarioTitle . '.png';
 }