BladeExtendsTest.php 1.4 KB

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