1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
<?php
namespace Illuminate\Tests\View\Blade;
class BladeExtendsTest extends AbstractBladeTestCase
{
public function testExtendsAreCompiled()
{
$string = '@extends(\'foo\')
test';
$expected = 'test'.PHP_EOL.'<?php echo $__env->make(\'foo\', \Illuminate\Support\Arr::except(get_defined_vars(), [\'__data\', \'__path\']))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
$string = '@extends(name(foo))'.PHP_EOL.'test';
$expected = 'test'.PHP_EOL.'<?php echo $__env->make(name(foo), \Illuminate\Support\Arr::except(get_defined_vars(), [\'__data\', \'__path\']))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
public function testSequentialCompileStringCalls()
{
$string = '@extends(\'foo\')
test';
$expected = 'test'.PHP_EOL.'<?php echo $__env->make(\'foo\', \Illuminate\Support\Arr::except(get_defined_vars(), [\'__data\', \'__path\']))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
// use the same compiler instance to compile another template with @extends directive
$string = '@extends(name(foo))'.PHP_EOL.'test';
$expected = 'test'.PHP_EOL.'<?php echo $__env->make(name(foo), \Illuminate\Support\Arr::except(get_defined_vars(), [\'__data\', \'__path\']))->render(); ?>';
$this->assertEquals($expected, $this->compiler->compileString($string));
}
}
|