/** * @param DefinitionInterface $definition * @return bool */ public function runTestDefinition(DefinitionInterface $definition) : bool { $context = new Context(); $this->eventDispatcher->dispatch(self::EVENT_TEST_WILL_RUN, new Event($definition, $context)); $this->prepareTestRunnerForDefinition($definition); $exception = null; set_error_handler([$this, 'handleError']); error_clear_last(); try { $this->performTest($definition, $context); } catch (\Error $exception) { } catch (\Exception $exception) { } $this->environment->reset(); $this->eventDispatcher->dispatch(self::EVENT_TEST_DID_RUN, new Event($definition, $context)); if ($exception !== null) { $this->printException($definition, $exception); return false; } $lastError = error_get_last(); if (!$lastError) { $this->printSuccess($definition); return true; } $this->printException($definition, $this->createExceptionFromError($lastError)); return false; }
/** * */ private function initEnvironment() { try { $locales = [LC_CTYPE => setlocale(LC_CTYPE, 0), LC_NUMERIC => setlocale(LC_NUMERIC, 0), LC_TIME => setlocale(LC_TIME, 0), LC_COLLATE => setlocale(LC_COLLATE, 0), LC_MONETARY => setlocale(LC_MONETARY, 0), LC_ALL => setlocale(LC_ALL, 0), LC_MESSAGES => setlocale(LC_MESSAGES, 0)]; $this->environment = $this->objectManager->get(Environment::class); $this->environment->store(date_default_timezone_get(), $locales, error_reporting(null), $GLOBALS, $_ENV, $_GET, $_POST, $_COOKIE, $_SERVER, $_SESSION, $_FILES, $_REQUEST); $this->environment->reset(); } catch (\TypeError $error) { echo $error; } }