public function updateActor(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     $modules = $e->getSuite()->getModules();
     $actorActionsFile = Configuration::supportDir() . '_generated' . DIRECTORY_SEPARATOR . $settings['class_name'] . 'Actions.php';
     if (!file_exists($actorActionsFile)) {
         codecept_debug("Generating {$settings['class_name']}Actions...");
         $this->generateActorActions($actorActionsFile, $settings);
         return;
     }
     // load actor class to see hash
     $handle = @fopen($actorActionsFile, "r");
     if ($handle and is_writable($actorActionsFile)) {
         $line = @fgets($handle);
         if (preg_match('~\\[STAMP\\] ([a-f0-9]*)~', $line, $matches)) {
             $hash = $matches[1];
             $currentHash = Actions::genHash($modules, $settings);
             // regenerate actor class when hashes do not match
             if ($hash != $currentHash) {
                 codecept_debug("Rebuilding {$settings['class_name']}...");
                 @fclose($handle);
                 $this->generateActorActions($actorActionsFile, $settings);
                 return;
             }
         }
         @fclose($handle);
     }
 }
Exemple #2
0
 public function beforeSuite(SuiteEvent $e)
 {
     $this->applySettings($e->getSettings());
     if (!$this->isEnabled()) {
         return;
     }
     $this->applyFilter($e->getResult());
 }
Exemple #3
0
 public function beforeSuite(SuiteEvent $e)
 {
     $this->applySettings($e->getSettings());
     $this->module = $this->getServerConnectionModule($e->getSuite()->getModules());
     if (!$this->isEnabled()) {
         return;
     }
     $this->applyFilter($e->getResult());
 }
Exemple #4
0
 public function moduleInit(SuiteEvent $event)
 {
     $settings = $event->getSettings();
     $config = [];
     if (array_key_exists("extensions", $settings) && array_key_exists("enabled", $settings["extensions"])) {
         if (in_array(trim(get_class($this), "/"), $settings["extensions"]["enabled"])) {
             $this->startServer();
         }
     }
 }
 public function handle(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     if ($settings['error_level']) {
         $this->errorLevel = $settings['error_level'];
     }
     error_reporting(eval("return {$this->errorLevel};"));
     set_error_handler([$this, 'errorHandler']);
     register_shutdown_function([$this, 'shutdownHandler']);
 }
Exemple #6
0
 public function beforeSuite(SuiteEvent $e)
 {
     $suite = $e->getSuite();
     if (!$suite instanceof Suite) {
         return;
     }
     $this->modules = $suite->getModules();
     foreach ($this->modules as $module) {
         $module->_beforeSuite($e->getSettings());
     }
 }
Exemple #7
0
 public function loadBootstrap(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     if (!isset($settings['bootstrap'])) {
         return;
     }
     $bootstrap = $settings['path'] . $settings['bootstrap'];
     if (!is_file($bootstrap)) {
         throw new ConfigurationException("Bootstrap file {$bootstrap} can't be loaded");
     }
     require_once $bootstrap;
 }
 public function handle(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     if ($settings['error_level']) {
         $this->errorLevel = eval("return {$settings['error_level']};");
     }
     error_reporting($this->errorLevel);
     // We must register shutdown function before deprecation error handler to restore previous error handler
     // and silence DeprecationErrorHandler yelling about 'THE ERROR HANDLER HAS CHANGED!'
     register_shutdown_function([$this, 'shutdownHandler']);
     $this->registerDeprecationErrorHandler();
     $this->oldHandler = set_error_handler([$this, 'errorHandler']);
 }
Exemple #9
0
 public function unlink(\Codeception\Event\SuiteEvent $e)
 {
     $rootFolder = $this->getRootFolder();
     $destination = $this->getDestination($rootFolder, $e->getSettings());
     if ($this->filesystem->file_exists($destination)) {
         $unlinked = $this->filesystem->unlink($destination);
         if (!$unlinked) {
             // let's not kill the suite but let's notify the user
             $this->writeln('Could not unlink file [' . $destination . '], manual removal is required.');
         }
         $this->writeln('Unliked plugin folder [' . $destination . ']');
     }
 }
 public function beforeSuite(SuiteEvent $e)
 {
     $this->namespace = "";
     $settings = $e->getSettings();
     if (isset($settings['namespace'])) {
         $this->namespace = $settings['namespace'];
     }
     $this->message("%s Tests (%d) ")->with(ucfirst($e->getSuite()->getName()), count($e->getSuite()->tests()))->style('bold')->width($this->width, '-')->prepend("\n")->writeln();
     if ($e->getSuite() instanceof Suite) {
         $message = $this->message(implode(', ', array_map(function ($module) {
             return $module->_getName();
         }, $e->getSuite()->getModules())));
         $message->style('info')->prepend('Modules: ')->writeln(OutputInterface::VERBOSITY_VERBOSE);
     }
     $this->message('')->width($this->width, '-')->writeln(OutputInterface::VERBOSITY_VERBOSE);
 }
Exemple #11
0
 /**
  * @test
  * it should allow specifying the root folder in the configuration
  */
 public function it_should_allow_specifying_the_root_folder_in_the_configuration()
 {
     $rootFolder = __DIR__;
     $defaultDestinationFolder = '/default';
     $defaultDestination = $defaultDestinationFolder;
     $envDestinations = ['default' => $defaultDestinationFolder];
     $this->config = ['mode' => 'plugin', 'destination' => $envDestinations, 'rootFolder' => $rootFolder];
     $this->event->getSettings()->willReturn(['current_environment' => 'default']);
     $this->filesystem->file_exists($defaultDestination . DIRECTORY_SEPARATOR . basename($rootFolder))->willReturn(false);
     $this->filesystem->is_dir($defaultDestinationFolder)->willReturn(true);
     $this->filesystem->is_writeable($defaultDestinationFolder)->willReturn(true);
     $this->filesystem->is_dir($rootFolder)->willReturn(true);
     $this->filesystem->is_readable($rootFolder)->willReturn(true);
     $this->filesystem->symlink(rtrim($rootFolder, DIRECTORY_SEPARATOR), $defaultDestination . DIRECTORY_SEPARATOR . basename($rootFolder), true)->shouldBeCalled();
     $sut = $this->make_instance();
     $sut->symlink($this->event->reveal());
 }
Exemple #12
0
 public function beforeSuite(SuiteEvent $e)
 {
     $this->module = $this->getServerConnectionModule();
     $this->applySettings($e->getSettings());
     if (!$this->isEnabled()) {
         return;
     }
     $this->suiteName = $e->getSuite()->baseName;
     if ($this->settings['remote_config']) {
         $this->addC3AccessHeader(self::COVERAGE_HEADER_CONFIG, $this->settings['remote_config']);
     }
     $knock = $this->c3Request('clear');
     if ($knock === false) {
         throw new RemoteException('
             CodeCoverage Error.
             Check the file "c3.php" is included in your application.
             We tried to access "/c3/report/clear" but this URI was not accessible.
             You can review actual error messages in c3tmp dir.
             ');
     }
 }
Exemple #13
0
 public function updateGuy(SuiteEvent $e)
 {
     $settings = $e->getSettings();
     $guyFile = $settings['path'] . $settings['class_name'] . '.php';
     // load guy class to see hash
     $handle = @fopen($guyFile, "r");
     if ($handle and is_writable($guyFile)) {
         $line = @fgets($handle);
         if (preg_match('~\\[STAMP\\] ([a-f0-9]*)~', $line, $matches)) {
             $hash = $matches[1];
             $currentHash = Actor::genHash(SuiteManager::$actions, $settings);
             // regenerate guy class when hashes do not match
             if ($hash != $currentHash) {
                 codecept_debug("Rebuilding {$settings['class_name']}...");
                 $guyGenerator = new Actor($settings);
                 @fclose($handle);
                 $generated = $guyGenerator->produce();
                 @file_put_contents($guyFile, $generated);
                 return;
             }
         }
         @fclose($handle);
     }
 }
 public function afterSuite(\Codeception\Event\SuiteEvent $e)
 {
     $name = $e->getSettings()['class_name'];
     teamcity_console_logger(MessageTemplate::TestSuiteEnd($name));
     teamcity_console_logger(MessageTemplate::BlockEnd($name));
 }
Exemple #15
0
 public function beforeSuite(SuiteEvent $e)
 {
     foreach (SuiteManager::$modules as $module) {
         $module->_beforeSuite($e->getSettings());
     }
 }
 /**
  * @codeCoverageIgnore
  */
 public function beforeSuite(\Codeception\Event\SuiteEvent $e)
 {
     static::$suite_config = $e->getSettings();
 }
 /**
  * Before suite is executed
  */
 public function beforeSuite(\Codeception\Event\SuiteEvent $e)
 {
     $this->currentSuite = $e->getSuite()->getName();
     $this->currentSuiteBaseName = $e->getSuite()->getBaseName();
     $settings = $e->getSettings();
     if (isset($settings['current_environment'])) {
         $this->currentEnvironment = explode(',', $settings['current_environment']);
     } else {
         $this->currentEnvironment = [];
     }
     $this->runConfigGroup('BeforeSuite');
 }
 public function beforeSuite(SuiteEvent $event)
 {
     if (!is_null($this->resource)) {
         $this->stopServer();
     }
     $settings = $event->getSettings();
     $config = [];
     if (array_key_exists("extensions", $settings)) {
         if (array_key_exists("config", $settings["extensions"])) {
             if (array_key_exists("Codeception\\Extension\\PhpBuiltinServer", $settings["extensions"]["config"])) {
                 $config = $settings["extensions"]["config"]["Codeception\\Extension\\PhpBuiltinServer"];
             }
         }
     }
     $this->config = array_merge($this->orgConfig, $config);
     $this->validateConfig();
     $this->startServer();
     if (isset($settings["extensions"]["enabled"]) && in_array(trim(get_class($this), "/"), $settings["extensions"]["enabled"])) {
         $this->startServer();
     }
     // dummy to keep reference to this instance, so that it wouldn't be destroyed immediately
 }