/**
  * Returns array of feature paths configured for the provided suite.
  *
  * @param Suite $suite
  *
  * @return string[]
  *
  * @throws SuiteConfigurationException If `paths` setting is not an array
  */
 private function getSuitePaths(Suite $suite)
 {
     if (!is_array($suite->getSetting('paths'))) {
         throw new SuiteConfigurationException(sprintf('`paths` setting of the "%s" suite is expected to be an array, %s given.', $suite->getName(), gettype($suite->getSetting('paths'))), $suite->getName());
     }
     return $suite->getSetting('paths');
 }
    private function prepare()
    {
        $em = $this->getService('models');
        $em->generateAttributeModels();
        //refresh s_core_templates
        $this->registerErrorHandler();
        $this->getService('theme_installer')->synchronize();
        restore_error_handler();
        //get the template id
        $sql = sprintf('SELECT id FROM `s_core_templates` WHERE template = "%s"', self::$suite->getSetting('template'));
        $templateId = $this->getService('db')->fetchOne($sql);
        if (!$templateId) {
            throw new \RuntimeException(sprintf("Unable to find template by name %s", self::$suite->getSetting('template')));
        }
        //set the template for shop "Deutsch" and activate SEPA payment method
        $sql = <<<EOD
            UPDATE `s_core_shops` SET `template_id`= {$templateId} WHERE `id` = 1;
            UPDATE `s_core_paymentmeans` SET `active`= 1;
EOD;
        $this->getService('db')->exec($sql);
        Helper::setCurrentLanguage('de');
        /** @var \Shopware\Bundle\PluginInstallerBundle\Service\InstallerService $pluginManager */
        $pluginManager = $this->getService('shopware_plugininstaller.plugin_manager');
        // hack to prevent behat error handler kicking in.
        $this->registerErrorHandler();
        $pluginManager->refreshPluginList();
        restore_error_handler();
        $plugin = $pluginManager->getPluginByName('Notification');
        $pluginManager->installPlugin($plugin);
        $pluginManager->activatePlugin($plugin);
    }
 public function suiteNeedsWebserver(Suite $suite)
 {
     if (!count($this->suiteNames)) {
         return true;
     }
     return in_array($suite->getName(), $this->suiteNames);
 }
 /**
  * Checks if Feature matches specified filter.
  *
  * @param Suite  $suite
  * @param string $filterString
  *
  * @return Boolean
  */
 private function isSuiteMatch(Suite $suite, $filterString)
 {
     if ('/' === $filterString[0]) {
         return 1 === preg_match($filterString, $suite->getName());
     }
     return false !== mb_strpos($suite->getName(), $filterString, 0, 'utf8');
 }
 /**
  * {@inheritdoc}
  */
 public function setupSuite(Suite $suite)
 {
     foreach ($suite->getSetting('paths') as $locator) {
         if (0 !== strpos($locator, '@') && !is_dir($path = $this->locatePath($locator))) {
             $this->createFeatureDirectory($path);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function printHeader(Formatter $formatter, Suite $suite)
 {
     if ($this->statistics) {
         $this->statistics->reset();
     }
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $outputPrinter->createNewFile($suite->getName());
 }
 /**
  * Attempts to translate definition using translator and produce translated one on success.
  *
  * @param Suite       $suite
  * @param Definition  $definition
  * @param null|string $language
  *
  * @return Definition|TranslatedDefinition
  */
 public function translateDefinition(Suite $suite, Definition $definition, $language = null)
 {
     $assetsId = $suite->getName();
     $pattern = $definition->getPattern();
     $translatedPattern = $this->translator->trans($pattern, array(), $assetsId, $language);
     if ($pattern != $translatedPattern) {
         return new TranslatedDefinition($definition, $translatedPattern, $language);
     }
     return $definition;
 }
 /**
  * {@inheritdoc}
  */
 public function locateSpecifications(Suite $suite, $locator)
 {
     if (!is_file($locator) || 'rerun' !== pathinfo($locator, PATHINFO_EXTENSION)) {
         return new NoSpecificationsIterator($suite);
     }
     $scenarios = json_decode(trim(file_get_contents($locator)), true);
     if (empty($scenarios) || empty($scenarios[$suite->getName()])) {
         return new NoSpecificationsIterator($suite);
     }
     return new LazyFeatureIterator($suite, $this->gherkin, $scenarios[$suite->getName()]);
 }
 /**
  * {@inheritdoc}
  */
 public function locateSpecifications(Suite $suite, $locator)
 {
     if (!$suite instanceof SymfonyBundleSuite) {
         return new noSpecificationsIterator($suite);
     }
     $bundle = $suite->getBundle();
     if (0 !== strpos($locator, '@' . $bundle->getName())) {
         return new NoSpecificationsIterator($suite);
     }
     $locatorSuffix = substr($locator, strlen($bundle->getName()) + 1);
     return $this->baseLocator->locateSpecifications($suite, $bundle->getPath() . '/Features' . $locatorSuffix);
 }
 private function getJavascriptSession(Suite $suite)
 {
     if (!$suite->hasSetting('mink_javascript_session')) {
         if (null === $this->javascriptSession) {
             throw new ProcessingException('The @javascript tag cannot be used without enabling a javascript session');
         }
         return $this->javascriptSession;
     }
     $session = $suite->getSetting('mink_javascript_session');
     if (!is_string($session)) {
         throw new SuiteConfigurationException(sprintf('`mink_javascript_session` setting of the "%s" suite is expected to be a string, %s given.', $suite->getName(), gettype($session)), $suite->getName());
     }
     if (!in_array($session, $this->availableJavascriptSessions)) {
         throw new SuiteConfigurationException(sprintf('`mink_javascript_session` setting of the "%s" suite is not a javascript session. %s given but expected one of %s.', $suite->getName(), $session, implode(', ', $this->availableJavascriptSessions)), $suite->getName());
     }
     return $session;
 }
 /**
  * Returns array of context classes configured for the provided suite.
  *
  * @param Suite $suite
  *
  * @return string[]
  *
  * @throws SuiteConfigurationException If `contexts` setting is not an array
  */
 private function getSuiteContexts(Suite $suite)
 {
     $contexts = $suite->getSetting('contexts');
     if (!is_array($contexts)) {
         throw new SuiteConfigurationException(sprintf('`contexts` setting of the "%s" suite is expected to be an array, `%s` given.', $suite->getName(), gettype($contexts)), $suite->getName());
     }
     return $contexts;
 }
 /**
  * Extracts the formatted footer from the definition.
  *
  * @param Suite      $suite
  * @param Definition $definition
  *
  * @return string[]
  */
 private function extractFooter(Suite $suite, Definition $definition)
 {
     $lines = array();
     $lines[] = strtr('{space}<def_dimmed>|</def_dimmed> at `{path}`', array('{space}' => str_pad('', mb_strlen($suite->getName(), 'utf8') + 1), '{path}' => $definition->getPath()));
     return $lines;
 }
 /**
  * Creates filter of provided type.
  *
  * @param string $type
  * @param string $filterString
  * @param Suite  $suite
  *
  * @return FilterInterface
  *
  * @throws SuiteConfigurationException If filter type is not recognised
  */
 private function createFilter($type, $filterString, Suite $suite)
 {
     if ('role' === $type) {
         return new RoleFilter($filterString);
     }
     if ('name' === $type) {
         return new NameFilter($filterString);
     }
     if ('tags' === $type) {
         return new TagFilter($filterString);
     }
     throw new SuiteConfigurationException(sprintf('`%s` filter is not supported by the `%s` suite. Supported types are `%s`.', $type, $suite->getName(), implode('`, `', array('role', 'name', 'tags'))), $suite->getName());
 }
 public function initialize(Suite $suite, Spec $spec)
 {
     $this->mink->setDefaultSessionName($suite->getSetting('mink_session'));
     $this->mink->resetSessions();
 }
 function it_says_a_server_is_needed_when_nothing_was_specified(Suite $suite)
 {
     $this->beConstructedWith([]);
     $suite->getName()->willReturn('domainsuite');
     $this->suiteNeedsWebserver($suite)->shouldReturn(true);
 }