36c7dd8c11cab5340bcf031483be21b85f5e3d09
[yaffs-website] / vendor / psy / psysh / test / Exception / FatalErrorExceptionTest.php
1 <?php
2
3 /*
4  * This file is part of Psy Shell.
5  *
6  * (c) 2012-2018 Justin Hileman
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Psy\Test\Exception;
13
14 use Psy\Exception\FatalErrorException;
15
16 class FatalErrorExceptionTest extends \PHPUnit\Framework\TestCase
17 {
18     public function testInstance()
19     {
20         $e = new FatalErrorException();
21
22         $this->assertInstanceOf('Psy\Exception\Exception', $e);
23         $this->assertInstanceOf('ErrorException', $e);
24         $this->assertInstanceOf('Psy\Exception\FatalErrorException', $e);
25     }
26
27     public function testMessage()
28     {
29         $e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);
30
31         $this->assertSame('{msg}', $e->getRawMessage());
32         $this->assertContains('{msg}', $e->getMessage());
33         $this->assertContains('{filename}', $e->getMessage());
34         $this->assertContains('line 13', $e->getMessage());
35     }
36
37     public function testMessageWithNoFilename()
38     {
39         $e = new FatalErrorException('{msg}');
40
41         $this->assertSame('{msg}', $e->getRawMessage());
42         $this->assertContains('{msg}', $e->getMessage());
43         $this->assertContains('eval()\'d code', $e->getMessage());
44     }
45
46     public function testNegativeOneLineNumberIgnored()
47     {
48         $e = new FatalErrorException('{msg}', 0, 1, null, -1);
49         $this->assertEquals(0, $e->getLine());
50     }
51 }