|
@@ -18,6 +18,20 @@ class BladeTest extends PHPUnit_Framework_TestCase {
|
|
|
$this->assertEquals('<?php echo e($a); ?>', Blade::compile_string($blade2));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Test the compilation of comments statements.
|
|
|
+ *
|
|
|
+ * @group laravel
|
|
|
+ */
|
|
|
+ public function testCommentsAreConvertedProperly()
|
|
|
+ {
|
|
|
+ $blade1 = "{{-- This is a comment --}}";
|
|
|
+ $blade2 = "{{--\nThis is a\nmulti-line\ncomment.\n--}}";
|
|
|
+
|
|
|
+ $this->assertEquals("<?php /* This is a comment */ ?>\n", Blade::compile_string($blade1));
|
|
|
+ $this->assertEquals("<?php /* \nThis is a\nmulti-line\ncomment.\n */ ?>\n", Blade::compile_string($blade2));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Test the compilation of control structures.
|
|
|
*
|
|
@@ -29,11 +43,22 @@ class BladeTest extends PHPUnit_Framework_TestCase {
|
|
|
$blade2 = "@if (count(".'$something'.") > 0)\nfoo\n@endif";
|
|
|
$blade3 = "@if (true)\nfoo\n@elseif (false)\nbar\n@endif";
|
|
|
$blade4 = "@if (true)\nfoo\n@else\nbar\n@endif";
|
|
|
+ $blade5 = "@unless (count(".'$something'.") > 0)\nfoobar\n@endunless";
|
|
|
+ $blade6 = "@for (Foo::all() as ".'$foo'.")\nfoo\n@endfor";
|
|
|
+ $blade7 = "@foreach (Foo::all() as ".'$foo'.")\nfoo\n@endforeach";
|
|
|
+ $blade8 = "@forelse (Foo::all() as ".'$foo'.")\nfoo\n@empty\nbar\n@endforelse";
|
|
|
+ $blade9 = "@while (true)\nfoo\n@endwhile";
|
|
|
|
|
|
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade1));
|
|
|
$this->assertEquals("<?php if (count(".'$something'.") > 0): ?>\nfoo\n<?php endif; ?>", Blade::compile_string($blade2));
|
|
|
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php elseif (false): ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade3));
|
|
|
$this->assertEquals("<?php if (true): ?>\nfoo\n<?php else: ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade4));
|
|
|
+ $this->assertEquals("<?php if ( ! ( (count(".'$something'.") > 0))): ?>\nfoobar\n<?php endif; ?>", Blade::compile_string($blade5));
|
|
|
+ $this->assertEquals("<?php for (Foo::all() as ".'$foo'."): ?>\nfoo\n<?php endfor; ?>", Blade::compile_string($blade6));
|
|
|
+ $this->assertEquals("<?php foreach (Foo::all() as ".'$foo'."): ?>\nfoo\n<?php endforeach; ?>", Blade::compile_string($blade7));
|
|
|
+ $this->assertEquals("<?php if (count(Foo::all()) > 0): ?><?php foreach (Foo::all() as ".'$foo'."): ?>\nfoo\n<?php endforeach; ?><?php else: ?>\nbar\n<?php endif; ?>", Blade::compile_string($blade8));
|
|
|
+ $this->assertEquals("<?php while (true): ?>\nfoo\n<?php endwhile; ?>", Blade::compile_string($blade9));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -60,4 +85,28 @@ class BladeTest extends PHPUnit_Framework_TestCase {
|
|
|
$this->assertEquals("<?php \\Laravel\\Section::start('something'); ?>\nfoo\n<?php \\Laravel\\Section::stop(); ?>", Blade::compile_string($blade));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Test the compilation of include statements.
|
|
|
+ *
|
|
|
+ * @group laravel
|
|
|
+ */
|
|
|
+ public function testIncludesAreCompiledCorrectly()
|
|
|
+ {
|
|
|
+ $blade = "@include('user.profile')";
|
|
|
+
|
|
|
+ $this->assertEquals("<?php echo view('user.profile')->with(get_defined_vars())->render(); ?>", Blade::compile_string($blade));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test the compilation of render statements.
|
|
|
+ *
|
|
|
+ * @group laravel
|
|
|
+ */
|
|
|
+ public function testRendersAreCompiledCorrectly()
|
|
|
+ {
|
|
|
+ $blade = "@render('user.profile')";
|
|
|
+
|
|
|
+ $this->assertEquals("<?php echo render('user.profile'); ?>", Blade::compile_string($blade));
|
|
|
+ }
|
|
|
+
|
|
|
}
|