'; $this->assertEquals($expected, $this->compiler->compileString($string)); } public function testPhpStatementsWithoutExpressionAreIgnored() { $string = '@php'; $expected = '@php'; $this->assertEquals($expected, $this->compiler->compileString($string)); $string = '{{ "Ignore: @php" }}'; $expected = ''; $this->assertEquals($expected, $this->compiler->compileString($string)); } public function testPhpStatementsDontParseBladeCode() { $string = '@php echo "{{ This is a blade tag }}" @endphp'; $expected = ''; $this->assertEquals($expected, $this->compiler->compileString($string)); } public function testVerbatimAndPhpStatementsDontGetMixedUp() { $string = "@verbatim {{ Hello, I'm not blade! }}" ."\n@php echo 'And I'm not PHP!' @endphp" ."\n@endverbatim {{ 'I am Blade' }}" ."\n@php echo 'I am PHP {{ not Blade }}' @endphp"; $expected = " {{ Hello, I'm not blade! }}" ."\n@php echo 'And I'm not PHP!' @endphp" ."\n " ."\n\n"; $this->assertEquals($expected, $this->compiler->compileString($string)); } public function testStringWithParenthesisCannotBeCompiled() { $string = "@php(\$data = ['test' => ')'])"; $expected = " ')']); ?>"; $actual = " '); ?>'])"; $this->assertEquals($actual, $this->compiler->compileString($string)); } public function testStringWithEmptyStringDataValue() { $string = "@php(\$data = ['test' => ''])"; $expected = " '']); ?>"; $this->assertEquals($expected, $this->compiler->compileString($string)); $string = "@php(\$data = ['test' => \"\"])"; $expected = " \"\"]); ?>"; $this->assertEquals($expected, $this->compiler->compileString($string)); } public function testStringWithEscapingDataValue() { $string = "@php(\$data = ['test' => 'won\\'t break'])"; $expected = " 'won\\'t break']); ?>"; $this->assertEquals($expected, $this->compiler->compileString($string)); $string = "@php(\$data = ['test' => \"\\\"escaped\\\"\"])"; $expected = " \"\\\"escaped\\\"\"]); ?>"; $this->assertEquals($expected, $this->compiler->compileString($string)); } }