expectExceptionMessage( $expectedException );
}
$actualResult = $parser->parse( $html, [ 'minifyTemplate' => $minify ] );
$this->assertEquals( $expectedResult, $actualResult, $message );
}
public static function provideTestParse() {
return [
[
' {{foo}}
{{foo}}
', 'style' => 'baz', 'styleLang' => 'css', ], 'Basic test' ], [ '{{foo}}
', false, null, 'Missing ', false, null, 'Missing tag', 'No tag found', ], [ '{{foo}}
', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Missing ', false, null, 'Two style tags', 'More than one ', false, [ 'script' => 'bar', 'template' => '', 'style' => 'baz', 'styleLang' => 'css', ], 'Empty tag', ], [ '{{foo}}
', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Template with two root nodes', ], [ '{{foo}}
', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Template with comment outside: comment preserved when not minifiying', ], [ '{{foo}}
', true, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Template with comment outside: comment removed when minifiying', ], [ '{{foo}}
', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Template with comment inside: comment preserved when not minifying', ], [ '{{foo}}
', true, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Template with comment inside: comment removed when minifying', ], [ '{{foo}}
', true, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Comment before template tag', ], [ "\n\t{{foo}}\n{{bar}}\n\t
{{foo}}\n{{bar}}
tags', ], [ "\n\t\t\t\n", false, [ 'script' => 'blah', 'template' => "\n {{foo}}\n{{bar}}\n\t\t\t", 'style' => null, 'styleLang' => null, ], 'Single leading newline in{{foo}}\n{{bar}}\n\tis removed when not minifying', ], [ "\n\t\t\t\n", true, [ 'script' => 'blah', 'template' => "\n {{foo}}\n{{bar}}\n\t", 'style' => null, 'styleLang' => null, ], 'Single leading newline in{{foo}}\n{{bar}}is removed when minifying', ], [ "\n\t\t\t\n", false, [ 'script' => 'blah', 'template' => "\n\n {{foo}}\n{{bar}}\n\t\t\t", 'style' => null, 'styleLang' => null, ], 'Double leading newline in\n\n {{foo}}\n{{bar}}\n\tis preserved when not minifying', ], [ "\n\t\t\t\n", true, [ 'script' => 'blah', 'template' => "\n\n {{foo}}\n{{bar}}\n\t", 'style' => null, 'styleLang' => null, ], 'Double leading newline in\n\n {{foo}}\n{{bar}}is preserved when minifying', ], [ "!!!", false, [ 'script' => "var x = '!!!';", 'template' => "!!!", 'style' => null, 'styleLang' => null, ], 'Script tag with HTML string' ], [ '{{foo}}
', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => 'baz', 'styleLang' => 'less', ], 'Style tag with lang="less"', ], [ '{{foo}}
', false, null, 'Style tag with invalid language', '', false, null, 'Scoped style tag', '', false, null, 'Scoped style tag with lang="less"', '', false, null, '', false, null, ' tag', ' may not have any attributes' ], [ '{{foo}}
', false, null, '', false, [ 'script' => 'bar', 'template' => '{{foo}}
', 'style' => null, 'styleLang' => null, ], 'Attribute with : in the name' ], [ '{{foo}}', false, [ 'script' => 'bar', 'template' => '{{foo}}', 'style' => null, 'styleLang' => null, ], 'Attribute with @ in the name' ], [ '', false, [ 'script' => 'bar', 'template' => '', 'style' => null, 'styleLang' => null, ], 'Attribute with # in the name' ], [ '', false, [ 'script' => 'bar', 'template' => '
foo ', 'style' => null, 'styleLang' => null, ], 'Template with self-closing tag (broken)' ], ]; // phpcs:enable } }
foo