/** * 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'); }
/** * 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 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()]); }
public function suiteNeedsWebserver(Suite $suite) { if (!count($this->suiteNames)) { return true; } return in_array($suite->getName(), $this->suiteNames); }
/** * {@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; }
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()); }
function it_says_a_server_is_needed_when_nothing_was_specified(Suite $suite) { $this->beConstructedWith([]); $suite->getName()->willReturn('domainsuite'); $this->suiteNeedsWebserver($suite)->shouldReturn(true); }