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'); }
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); } } }
public function afterSuite(SuiteEvent $e) { $this->message()->width($this->width, '-')->writeln(); $deprecationMessages = Notification::all(); foreach ($deprecationMessages as $message) { $this->output->notification($message); } }
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)); } } }
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"); }
public function _initialize() { Notification::deprecate("Module Dbh is deprecated and will be removed in 2.2"); }
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}"); }
public function running() { \Codeception\Lib\Notification::deprecate("Scenario is always running. Please remove \$scenario->running() call.", $this->getFeature()); return true; }
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'); } }
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); } }