More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / psy / psysh / test / Exception / TypeErrorExceptionTest.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\TypeErrorException;
15
16 class TypeErrorExceptionTest extends \PHPUnit\Framework\TestCase
17 {
18     public function testException()
19     {
20         $e = new TypeErrorException('{{message}}', 13);
21
22         $this->assertInstanceOf('Psy\Exception\Exception', $e);
23         $this->assertInstanceOf('Psy\Exception\TypeErrorException', $e);
24
25         $this->assertEquals('TypeError: {{message}}', $e->getMessage());
26         $this->assertEquals('{{message}}', $e->getRawMessage());
27         $this->assertEquals(13, $e->getCode());
28     }
29
30     public function testStripsEvalFromMessage()
31     {
32         $message = 'Something or other, called in line 10: eval()\'d code';
33         $e = new TypeErrorException($message);
34         $this->assertEquals($message, $e->getRawMessage());
35         $this->assertEquals('TypeError: Something or other', $e->getMessage());
36     }
37
38     public function testFromTypeError()
39     {
40         if (version_compare(PHP_VERSION, '7.0.0', '<')) {
41             $this->markTestSkipped();
42         }
43
44         $previous = new \TypeError('{{message}}', 13);
45         $e = TypeErrorException::fromTypeError($previous);
46
47         $this->assertInstanceOf('Psy\Exception\TypeErrorException', $e);
48         $this->assertEquals('TypeError: {{message}}', $e->getMessage());
49         $this->assertEquals('{{message}}', $e->getRawMessage());
50         $this->assertEquals(13, $e->getCode());
51     }
52 }