/
razxc
/
telescope.php
Обзор
Документация
Войти
/
razxc
/
telescope.php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
tests/Tests.php
56 строк
1 KB
Alexandr Haritonov
Initial commit. Telescope 6.0.0
29 мар 2026, 11:23
29 мар 2026, 11:23
02aa6e9
Код
Авторство
О чём код?
<?php namespace razxc\telescope; use PHPUnit\Framework\TestCase; class Tests extends TestCase { public function setUp(): void { if(! is_file($config = __DIR__.'/../.telescope.ini')) { self::markTestIncomplete("Tests required '$config' configuration file"); } } public function testInCli() { $script = realpath(__DIR__ . '/reaction.php'); if (PHP_VERSION_ID < 80000) { $exMess = '[E_NOTICE #8] Undefined variable: b'; } else { $exMess = '[E_WARNING #2] Undefined variable $b'; } $out = $this->execPhpCmd($script, "error 2>&1"); $sample = <<<EOT ******************************************************************************** * $exMess * $script: EOT; self::assertStringStartsWith($sample, $out); $out = $this->execPhpCmd($script, "exception 2>&1"); $sample = <<<EOT ******************************************************************************** * [Exception] Exception test * $script: EOT; self::assertStringStartsWith($sample, $out); $out = $this->execPhpCmd($script, "fatal 2>&1"); $sample = <<<EOT ******************************************************************************** * [Error] Call to undefined function fatalError() * $script: EOT; self::assertStringStartsWith($sample, $out); } private function execPhpCmd($script, $args) { $php = sprintf('php -d sendmail_path="%s/fake-sendmail.sh -t -i"', __DIR__); return shell_exec($php . ' ' . $script . ' ' . $args); } }