File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1111namespace AdrianSuter \Autoload \Override \Tests ;
1212
1313use AdrianSuter \Autoload \Override \CodeConverter ;
14+ use PhpParser \Parser ;
1415use PHPUnit \Framework \TestCase ;
16+ use Prophecy \Argument ;
17+ use Prophecy \Prophecy \MethodProphecy ;
18+ use RuntimeException ;
1519
1620class CodeConverterTest extends TestCase
1721{
18- public function testA ()
22+ public function testConvert (): void
1923 {
2024 $ converter = new CodeConverter ();
2125 $ this ->assertEquals (
2226 '<?php echo \foo\rand(0, 9); ' ,
2327 $ converter ->convert ('<?php echo \rand(0, 9); ' , ['\rand ' => 'foo\rand ' ])
2428 );
2529 }
30+
31+ public function testExceptionIfParserReturnsNull (): void
32+ {
33+ $ this ->expectException (RuntimeException::class);
34+ $ this ->expectExceptionMessage ('Code could not be parsed. ' );
35+
36+ $ parserProphecy = $ this ->prophesize (Parser::class);
37+
38+ $ parseProphecy = new MethodProphecy ($ parserProphecy , 'parse ' , [Argument::any ()]);
39+ $ parseProphecy ->willReturn (null );
40+
41+ /** @var Parser $parser */
42+ $ parser = $ parserProphecy ->reveal ();
43+
44+ $ converter = new CodeConverter (null , $ parser );
45+ $ converter ->convert ('<?php echo "1"; ' , []);
46+ }
2647}
You can’t perform that action at this time.
0 commit comments