First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
34
vendor/psy/psysh/test/Psy/Test/Exception/BreakExceptionTest.php
vendored
Normal file
34
vendor/psy/psysh/test/Psy/Test/Exception/BreakExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?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\BreakException;
|
||||
use Psy\Exception\Exception;
|
||||
|
||||
class BreakExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testInstance()
|
||||
{
|
||||
$e = new BreakException();
|
||||
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->assertTrue($e instanceof BreakException);
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$e = new BreakException('foo');
|
||||
|
||||
$this->assertContains('foo', $e->getMessage());
|
||||
$this->assertEquals('foo', $e->getRawMessage());
|
||||
}
|
||||
}
|
108
vendor/psy/psysh/test/Psy/Test/Exception/ErrorExceptionTest.php
vendored
Normal file
108
vendor/psy/psysh/test/Psy/Test/Exception/ErrorExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?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, 'Notice'),
|
||||
array(E_USER_DEPRECATED, 'Deprecated'),
|
||||
);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
46
vendor/psy/psysh/test/Psy/Test/Exception/FatalErrorExceptionTest.php
vendored
Normal file
46
vendor/psy/psysh/test/Psy/Test/Exception/FatalErrorExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?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\Exception;
|
||||
use Psy\Exception\FatalErrorException;
|
||||
|
||||
class FatalErrorExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testInstance()
|
||||
{
|
||||
$e = new FatalErrorException();
|
||||
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->assertTrue($e instanceof \ErrorException);
|
||||
$this->assertTrue($e instanceof FatalErrorException);
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);
|
||||
|
||||
$this->assertEquals('{msg}', $e->getRawMessage());
|
||||
$this->assertContains('{msg}', $e->getMessage());
|
||||
$this->assertContains('{filename}', $e->getMessage());
|
||||
$this->assertContains('line 13', $e->getMessage());
|
||||
}
|
||||
|
||||
public function testMessageWithNoFilename()
|
||||
{
|
||||
$e = new FatalErrorException('{msg}');
|
||||
|
||||
$this->assertEquals('{msg}', $e->getRawMessage());
|
||||
$this->assertContains('{msg}', $e->getMessage());
|
||||
$this->assertContains('eval()\'d code', $e->getMessage());
|
||||
}
|
||||
}
|
43
vendor/psy/psysh/test/Psy/Test/Exception/ParseErrorExceptionTest.php
vendored
Normal file
43
vendor/psy/psysh/test/Psy/Test/Exception/ParseErrorExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?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\Exception;
|
||||
use Psy\Exception\ParseErrorException;
|
||||
|
||||
class ParseErrorExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testInstance()
|
||||
{
|
||||
$e = new ParseErrorException();
|
||||
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->assertTrue($e instanceof \PhpParser\Error);
|
||||
$this->assertTrue($e instanceof ParseErrorException);
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$e = new ParseErrorException('{msg}', 1);
|
||||
|
||||
$this->assertContains('{msg}', $e->getMessage());
|
||||
$this->assertContains('PHP Parse error:', $e->getMessage());
|
||||
}
|
||||
|
||||
public function testConstructFromParseError()
|
||||
{
|
||||
$e = ParseErrorException::fromParseError(new \PhpParser\Error('{msg}'));
|
||||
|
||||
$this->assertContains('{msg}', $e->getRawMessage());
|
||||
$this->assertContains('PHP Parse error:', $e->getMessage());
|
||||
}
|
||||
}
|
31
vendor/psy/psysh/test/Psy/Test/Exception/RuntimeExceptionTest.php
vendored
Normal file
31
vendor/psy/psysh/test/Psy/Test/Exception/RuntimeExceptionTest.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?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\Exception;
|
||||
use Psy\Exception\RuntimeException;
|
||||
|
||||
class RuntimeExceptionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testException()
|
||||
{
|
||||
$msg = 'bananas';
|
||||
$e = new RuntimeException($msg);
|
||||
|
||||
$this->assertTrue($e instanceof Exception);
|
||||
$this->assertTrue($e instanceof \RuntimeException);
|
||||
$this->assertTrue($e instanceof RuntimeException);
|
||||
|
||||
$this->assertEquals($msg, $e->getMessage());
|
||||
$this->assertEquals($msg, $e->getRawMessage());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue