示例#1
0
 private function getConfig()
 {
     $dispatcher = new \phmLabs\Components\Annovent\Dispatcher();
     \PhmLabs\Components\Init\Init::registerGlobalParameter('_eventDispatcher', $dispatcher);
     \PhmLabs\Components\Init\Init::registerGlobalParameter('_output', null);
     return new \whm\Smoke\Config\Configuration(new \whm\Html\Uri('http://www.example.com'), $dispatcher, \Symfony\Component\Yaml\Yaml::parse(file_get_contents(__DIR__ . '/fixtures/filter.yml')));
 }
示例#2
0
 public function init(OutputInterface $_output, Configuration $_configuration)
 {
     $this->output = $_output;
     $this->config = $_configuration;
     if ($_configuration->hasSection('reporter')) {
         $this->reporters = Init::initializeAll($_configuration->getSection('reporter'));
     }
 }
 public function init(Configuration $_configuration)
 {
     if ($_configuration->hasSection('responseRetriever')) {
         $this->retriever = Init::initialize($_configuration->getSection('responseRetriever'));
     } else {
         throw new \RuntimeException("No response retriever set. Please check the config file if a section 'responseRetriever' exists.");
     }
 }
示例#4
0
 public function init(Configuration $_configuration, Dispatcher $_eventDispatcher)
 {
     if ($_configuration->hasSection('stop')) {
         $strategies = $_configuration->getSection('stop');
         foreach ($strategies as $name => $strategy) {
             $this->stopStrategies[$name] = Init::initialize($strategy);
             $_eventDispatcher->connectListener($this->stopStrategies[$name]);
         }
     }
 }
示例#5
0
 protected function init(InputInterface $input, OutputInterface $output, $url = null)
 {
     if ($input->hasOption('bootstrap') && !is_null($input->getOption('bootstrap'))) {
         include $input->getOption('bootstrap');
     }
     $this->output = $output;
     $this->eventDispatcher = new Dispatcher();
     Init::registerGlobalParameter('_eventDispatcher', $this->eventDispatcher);
     Init::registerGlobalParameter('_output', $output);
     $this->writeSmokeCredentials($url);
 }
示例#6
0
文件: Crawler.php 项目: phmlabs/smoke
 private function initPageContainer($pageContainerArray)
 {
     $this->pageContainer = Init::initialize($pageContainerArray);
     // @todo this should be done inside a factory
     if ($this->pageContainer instanceof PatternAwareContainer) {
         if (array_key_exists('parameters', $pageContainerArray) && array_key_exists('pattern', $pageContainerArray['parameters'])) {
             foreach ($pageContainerArray['parameters']['pattern'] as $name => $pattern) {
                 $this->pageContainer->registerPattern($name, $pattern);
             }
         }
     }
 }
示例#7
0
 private function renderRuleOutput()
 {
     $this->output->writeln("\n\n <comment>Rules and Violations:</comment> \n");
     foreach ($this->rules as $ruleKey => $rule) {
         $info = Init::getInitInformationByClass($rule);
         $failedUrls = $this->getFailedUrls($ruleKey);
         if (count($failedUrls) > 0) {
             $this->output->writeln('  <error> ' . get_class($rule) . ' </error>');
         } else {
             $this->output->writeln('  <info> ' . get_class($rule) . ' </info>');
         }
         $this->output->writeln('   ' . str_replace("\n", "\n   ", $info['documentation']) . "\n");
         foreach ($failedUrls as $failedUrl) {
             $this->output->writeln('   - ' . $failedUrl);
         }
         $this->output->writeln('');
     }
 }
示例#8
0
 /**
  * Runs the analysis of the given website with all given parameters.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->init($input, $output);
     $config = $this->initConfiguration($input->getOption('config_file'));
     $rules = $config->getRules();
     foreach ($rules as $name => $rule) {
         $info = Init::getInitInformationByClass(get_class($rule));
         $output->writeln('  ' . $name . ':');
         $output->writeln('    class: ' . get_class($rule));
         $output->writeln('    description: ' . str_replace("\n", "\n                 ", $info['documentation']));
         if (count($info['parameters']) > 0) {
             $output->writeln('    parameter:');
             foreach ($info['parameters'] as $parameter) {
                 $output->writeln('      ' . $parameter['name'] . ': ' . $parameter['description'] . ' (default: ' . $parameter['default'] . ')');
             }
         }
         $output->writeln('');
     }
 }
示例#9
0
 /**
  * This function initializes all the rules and sets the log level.
  *
  * @param array $rulesArray
  */
 private function initRules(array $rulesArray)
 {
     $this->rules = Init::initializeAll($rulesArray);
 }