Skip to content

Commit 9400199

Browse files
committed
Test root path include
1 parent c85e276 commit 9400199

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

tests/Minify/BlockExtractorTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,14 @@ public function testSetNodeValue()
6666

6767
self::assertSame("'after'", $fakeNode->getBarValue());
6868
}
69+
70+
public function testPathForWrongNode()
71+
{
72+
require_once __DIR__ . '/Fixture/FakeNode.php';
73+
require_once __DIR__ . '/Fixture/BlockExtractorTester.php';
74+
75+
$extractor = new BlockExtractorTester((object) array());
76+
77+
self::assertNull($extractor->getPathForWrongNode());
78+
}
6979
}

tests/Minify/Fixture/BlockExtractorTester.php

+5
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ public function changeValue($node)
2424
{
2525
$this->setNodeValue($node, 'bar', 'after');
2626
}
27+
28+
public function getPathForWrongNode()
29+
{
30+
return $this->getNodePath(new \stdClass());
31+
}
2732
}

tests/MinifyTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,11 @@ public function testProductionWithMinify()
187187
$this->cleanTempDir();
188188
}
189189

190-
public function testProductionWithConcat()
190+
/**
191+
* @testWith ["test-concat"]
192+
* ["relative/test-root"]
193+
*/
194+
public function testProductionWithConcat($path)
191195
{
192196
$this->cleanTempDir();
193197
$outputDirectory = $this->getTempDir();
@@ -201,7 +205,7 @@ public function testProductionWithConcat()
201205
));
202206
$minify = new Minify($pug);
203207
$pug->addKeyword('concat', $minify);
204-
$html = static::simpleHtml($this->renderFile($pug, __DIR__ . '/test-concat.pug'));
208+
$html = static::simpleHtml($this->renderFile($pug, __DIR__ . '/' . $path . '.pug'));
205209
$expected = static::simpleHtml(file_get_contents(__DIR__ . '/prod-concat.html'));
206210

207211
self::assertSimilar($expected, $html);

tests/relative/test-root.pug

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
doctype 5
2+
html
3+
head
4+
title Foo
5+
concat top
6+
script(src="coffee/test.coffee")
7+
script(src="react-pug/test.jsxp" type="text/babel")
8+
link(rel="stylesheet" href="less/test.less")
9+
link(rel="stylesheet" href="stylus/test.styl")
10+
body
11+
h1 Foobar
12+
concat bottom
13+
script(src="react/test.jsx" type="text/babel")
14+
script(src="coffee-pug/test.cofp")
15+
concat empty

0 commit comments

Comments
 (0)