Просмотр исходного кода

Move failing nested partial example into a test case.

See #214
Justin Hileman 11 лет назад
Родитель
Сommit
5d77f4de9a

+ 45 - 0
test/Mustache/Test/Functional/NestedPartialIndentTest.php

@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of Mustache.php.
+ *
+ * (c) 2010-2014 Justin Hileman
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * @group functional
+ * @group partials
+ */
+class Mustache_Test_Functional_NestedPartialIndentTest extends PHPUnit_Framework_TestCase
+{
+    /**
+     * @dataProvider partialsAndStuff
+     */
+    public function testNestedPartialsAreIndentedProperly($src, array $partials, $expected)
+    {
+        $m = new Mustache_Engine(array(
+            'partials' => $partials
+        ));
+        $tpl = $m->loadTemplate($src);
+        $this->assertEquals($expected, $tpl->render());
+    }
+
+    public function partialsAndStuff()
+    {
+        $partials = array(
+            'a' => ' {{> b }}',
+            'b' => ' {{> d }}',
+            'c' => ' {{> d }}{{> d }}',
+            'd' => 'D!',
+        );
+
+        return array(
+            array(' {{> a }}', $partials, '   D!'),
+            array(' {{> b }}', $partials, '  D!'),
+            array(' {{> c }}', $partials, '  D!D!'),
+        );
+    }
+}

+ 0 - 3
test/fixtures/examples/nested_partials/nested_partials.txt

@@ -3,8 +3,5 @@
     <third>
       FOURTH!
     </third>
-    <third>
-      FOURTH!FOURTH!
-    </third>
   </second>
 </first>

+ 0 - 1
test/fixtures/examples/nested_partials/partials/fourth_inline.mustache

@@ -1 +0,0 @@
-{{ val }}

+ 0 - 3
test/fixtures/examples/nested_partials/partials/third.mustache

@@ -1,6 +1,3 @@
 <third>
   {{> fourth }}
 </third>
-<third>
-  {{> fourth_inline }}{{> fourth_inline }}
-</third>