Exemple #1
0
 protected function buildActorsForConfig($configFile)
 {
     $config = $this->getGlobalConfig($configFile);
     $suites = $this->getSuites($configFile);
     $path = pathinfo($configFile);
     $dir = isset($path['dirname']) ? $path['dirname'] : getcwd();
     foreach ($config['include'] as $subConfig) {
         $this->output->writeln("<comment>Included Configuration: {$subConfig}</comment>");
         $this->buildActorsForConfig($dir . DIRECTORY_SEPARATOR . $subConfig);
     }
     if (!empty($suites)) {
         $this->output->writeln("<info>Building Actor classes for suites: " . implode(', ', $suites) . '</info>');
     }
     foreach ($suites as $suite) {
         $settings = $this->getSuiteConfig($suite, $configFile);
         $actionsGenerator = new ActionsGenerator($settings);
         $contents = $actionsGenerator->produce();
         $actorGenerator = new ActorGenerator($settings);
         $file = $this->buildPath(Configuration::supportDir() . '_generated', $settings['class_name']) . $this->getClassName($settings['class_name']) . 'Actions.php';
         $this->save($file, $contents, true);
         $this->output->writeln('<info>' . Configuration::config()['namespace'] . '\\' . $actorGenerator->getActorName() . "</info> includes modules: " . implode(', ', $actorGenerator->getModules()));
         $this->output->writeln(" -> {$settings['class_name']}Actions.php generated successfully. " . $actionsGenerator->getNumMethods() . " methods added");
         $contents = $actorGenerator->produce();
         $file = $this->buildPath(Configuration::supportDir(), $settings['class_name']) . $this->getClassName($settings['class_name']) . '.php';
         if ($this->save($file, $contents)) {
             $this->output->writeln("{$settings['class_name']}.php created.");
         }
     }
 }
Exemple #2
0
 public function updateActor(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     $modules = $e->getSuite()->getModules();
     $actorFile = Configuration::supportDir() . '_generated' . DIRECTORY_SEPARATOR . $settings['class_name'] . 'Actions.php';
     // load guy class to see hash
     $handle = @fopen($actorFile, "r");
     if ($handle and is_writable($actorFile)) {
         $line = @fgets($handle);
         if (preg_match('~\\[STAMP\\] ([a-f0-9]*)~', $line, $matches)) {
             $hash = $matches[1];
             $currentHash = Actions::genHash($modules, $settings);
             // regenerate guy class when hashes do not match
             if ($hash != $currentHash) {
                 codecept_debug("Rebuilding {$settings['class_name']}...");
                 $actionsGenerator = new Actions($settings);
                 @fclose($handle);
                 $generated = $actionsGenerator->produce();
                 @file_put_contents($actorFile, $generated);
                 return;
             }
         }
         @fclose($handle);
     }
 }
 protected function generateActorActions($actorActionsFile, $settings)
 {
     if (!file_exists(Configuration::supportDir() . '_generated')) {
         @mkdir(Configuration::supportDir() . '_generated');
     }
     $actionsGenerator = new Actions($settings);
     $generated = $actionsGenerator->produce();
     @file_put_contents($actorActionsFile, $generated);
 }
Exemple #4
0
 private function buildActions(array $settings)
 {
     $actionsGenerator = new ActionsGenerator($settings);
     $this->output->writeln(" -> {$settings['class_name']}Actions.php generated successfully. " . $actionsGenerator->getNumMethods() . " methods added");
     $content = $actionsGenerator->produce();
     $file = $this->buildPath(Configuration::supportDir() . '_generated', $settings['class_name']);
     $file .= $this->getClassName($settings['class_name']) . 'Actions.php';
     return $this->save($file, $content, true);
 }