public function testDeprecationMessagesRespectErrorLevelSetting()
 {
     $errorHandler = new ErrorHandler();
     $suiteEvent = new SuiteEvent(new Suite(), null, ['error_level' => 'E_ERROR']);
     $errorHandler->handle($suiteEvent);
     Notification::all();
     //clear the messages
     $errorHandler->errorHandler(E_USER_DEPRECATED, 'deprecated message', __FILE__, __LINE__, []);
     $this->assertEquals([], Notification::all(), 'Deprecation message was added to notifications');
 }
Esempio n. 2
0
 public function parseScenarioOptions($code)
 {
     $comments = $this->matchComments($code);
     $this->attachMetadata($comments);
     // deprecated - parsing $scenario->xxx calls
     $metaData = ['group', 'env'];
     $phpCode = $this->stripComments($code);
     $scenario = $this->scenario;
     $feature = $scenario->getFeature();
     foreach ($metaData as $call) {
         $res = preg_match_all("~\\\$scenario->{$call}.*?;~", $phpCode, $matches);
         if (!$res) {
             continue;
         }
         foreach ($matches[0] as $line) {
             // run $scenario->group or $scenario->env
             \Codeception\Lib\Notification::deprecate("\$scenario->{$call}() is deprecated in favor of annotation: // @{$call}", $this->scenario->getFeature());
             eval($line);
         }
     }
 }
Esempio n. 3
0
 public function afterSuite(SuiteEvent $e)
 {
     $this->message()->width($this->width, '-')->writeln();
     $deprecationMessages = Notification::all();
     foreach ($deprecationMessages as $message) {
         $this->output->notification($message);
     }
 }
Esempio n. 4
0
 protected function checkEnvironmentExists(TestInterface $test)
 {
     $envs = $test->getMetadata()->getEnv();
     if (empty($envs)) {
         return;
     }
     if (!isset($this->settings['env'])) {
         Notification::warning("Environments are not configured", Descriptor::getTestFullName($test));
         return;
     }
     $availableEnvironments = array_keys($this->settings['env']);
     $listedEnvironments = explode(',', implode(',', $envs));
     foreach ($listedEnvironments as $env) {
         if (!in_array($env, $availableEnvironments)) {
             Notification::warning("Environment {$env} was not configured but used in test", Descriptor::getTestFullName($test));
         }
     }
 }
Esempio n. 5
0
 public function __call($method, $args)
 {
     // all methods were deprecated and removed from here
     Notification::deprecate("\$scenario->{$method}() was deprecated in 2.1 and removed. Don't use it");
 }
Esempio n. 6
0
 public function _initialize()
 {
     Notification::deprecate("Module Dbh is deprecated and will be removed in 2.2");
 }
Esempio n. 7
0
 private function handleDeprecationError($type, $message, $file, $line, $context)
 {
     if (!($this->errorLevel & $type)) {
         return;
     }
     if ($this->deprecationsInstalled && $this->oldHandler) {
         call_user_func($this->oldHandler, $type, $message, $file, $line, $context);
         return;
     }
     Notification::deprecate("{$message}", "{$file}:{$line}");
 }
Esempio n. 8
0
 public function running()
 {
     \Codeception\Lib\Notification::deprecate("Scenario is always running. Please remove \$scenario->running() call.", $this->getFeature());
     return true;
 }
Esempio n. 9
0
 private function defineConstants()
 {
     defined('YII_DEBUG') or define('YII_DEBUG', true);
     defined('YII_ENV') or define('YII_ENV', 'test');
     defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER', false);
     if (YII_ENV !== 'test') {
         Notification::warning("YII_ENV is not set to `test`, please add \n\n`define(\\'YII_ENV\\', \\'test\\');`\n\nto bootstrap file", 'Yii Framework');
     }
 }
Esempio n. 10
0
 public function afterSuite(SuiteEvent $e)
 {
     $this->message()->width($this->width, '-')->writeln();
     $messages = Notification::all();
     foreach (array_count_values($messages) as $message => $count) {
         if ($count > 1) {
             $message = $count . 'x ' . $message;
         }
         $this->output->notification($message);
     }
 }