/** * 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); }
/** * If using the Selenium2Driver, will automatically screenshot any failed * steps and save them in the current directory. * * Screenshots are named as "step-<step-line-number>-<timestamp>.png". * * @AfterStep * @param AfterStepScope $event */ public function takeScreenshotAfterFailedStep(AfterStepScope $event) { if (!$event->getTestResult()->isPassed()) { if ($this->getSession()->getDriver() instanceof Selenium2Driver) { $stepLine = $event->getStep()->getLine(); $time = time(); $fileName = "./step-{$stepLine}-{$time}.png"; if (is_writable('.')) { $screenshot = $this->getSession()->getDriver()->getScreenshot(); $stepText = $event->getStep()->getText(); if (file_put_contents($fileName, $screenshot)) { echo "Screenshot for '{$stepText}' placed in {$fileName}" . PHP_EOL; } else { echo "Screenshot failed: {$fileName} is not writable."; } } } } }
/** * @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; }
/** * @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'); }
/** * 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 screen shot when step fails. * And then pause everything * Works only with Selenium2Driver. * * @param AfterStepScope $scope * * @AfterStep */ public function myAfterStepHook(AfterStepScope $scope) { if (99 === $scope->getTestResult()->getResultCode()) { $driver = $this->getSession()->getDriver(); if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) { $name = preg_replace('%[^a-z0-9]%i', '_', array_pop($_SERVER['argv']) . ':' . $scope->getStep()->getText() . '_' . $driver->getCurrentUrl()); if (!file_exists('/tmp/behat')) { mkdir('/tmp/behat/'); } if (strlen($name) > 250) { $name = substr($name, 0, 200); $name .= date('YmdHis'); } $file = '/tmp/behat/' . $name . '.png'; file_put_contents($file, $this->getSession()->getDriver()->getScreenshot()); echo "Error Screen Shot Saved to {$file}"; xdebug_break(); } } }
/** * 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); }
/** * @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; }
/** * Take screen shot when step fails. * And then pause everything * Works only with Selenium2Driver. * * @param \Behat\Behat\Hook\Scope\AfterStepScope $scope * */ protected function screenShotFailedSteps(\Behat\Behat\Hook\Scope\AfterStepScope $scope, $caught = false) { if (99 === $scope->getTestResult()->getResultCode() || $caught) { $driver = $this->getSession()->getDriver(); if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) { $name = substr(preg_replace('%[^a-z0-9]%i', '_', array_pop($_SERVER['argv']) . ':' . $scope->getStep()->getText() . '_' . $driver->getCurrentUrl()), 0, 100); $file = '/tmp/behat_' . $name . '.png'; file_put_contents($file, $this->getSession()->getDriver()->getScreenshot()); echo "\n( Error Screen Shot Saved to {$file})\n\n"; } } }
/** * Take screenshot when step fails. * Works only with Selenium2Driver. * * @AfterStep */ public function takeScreenshotAfterFailedStep(AfterStepScope $scope) { if (!$scope->getTestResult()->isPassed()) { $driver = $this->getSession()->getDriver(); if (!$driver instanceof Selenium2Driver) { //throw new UnsupportedDriverActionException('Taking screenshots is not supported by %s, use Selenium2Driver instead.', $driver); return; } $step = $scope->getStep(); $step_line = $step->getLine(); $temp_path = $this->getContextParameter('temp_path'); $filename = $temp_path . '/stepAtLine' . $step_line . '.png'; $screenshot = $driver->getWebDriverSession()->screenshot(); file_put_contents($filename, base64_decode($screenshot)); echo "Saved Screenshot To {$filename} \n"; $filename = $temp_path . '/stepAtLine' . $step_line . '.html'; $source = $driver->getWebDriverSession()->source(); file_put_contents($filename, $source); echo "Saved Source To {$filename}\n"; } }
/** * @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); } }
/** * @AfterStep * * Take screenshot when step fails. */ public function takeScreenshotAfterFailedStep(AfterStepScope $scope) { if (self::ERROR_CODE === $scope->getTestResult()->getResultCode()) { $driver = $this->getSession()->getDriver(); // Get the text of the failed step. $failed_test_step = $scope->getStep()->getText(); // Remove quotes from the test step name. $failed_test_step = str_replace('"', '', $failed_test_step); // Set the screenshot location $filePath = $this->parameters['screenshots']; if ($driver instanceof \Behat\Mink\Driver\BrowserKitDriver) { $html_data = $this->getSession()->getDriver()->getContent(); $fileName = date(self::DATE_FORMAT_CONCISE) . '-' . $failed_test_step . '.html'; file_put_contents($filePath . '/' . $fileName, $html_data); return; } if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) { $fileName = date(self::DATE_FORMAT_CONCISE) . '-' . $failed_test_step . '.jpg'; $this->saveScreenshot($fileName, $filePath); return; } } }
/** * @AfterStep */ public function failScreenshots(AfterStepScope $scope) { if ($this->getSession()->getDriver() instanceof Selenium2Driver) { if (!$scope->getTestResult()->isPassed() && property_exists($this, "screenshots")) { if ($this->screenshots->onfail == true) { $scenarioLine = str_replace(' ', '_', $scope->getStep()->getLine()); $filename = sprintf('fail_on_line_%s_%s.png', $scenarioLine, date('H-i-s')); $this->makeScreenshot($filename); } } } }
/** * 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 * * @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'); } } }