Accommodate formatter changes

This commit is contained in:
Kijin Sung 2021-01-06 21:50:27 +09:00
parent aabc7ac55e
commit 3cdcd2dcc0
2 changed files with 18 additions and 13 deletions

View file

@ -224,7 +224,7 @@ class Formatter
try
{
$scss_compiler = new \ScssPhp\ScssPhp\Compiler;
$scss_compiler->setFormatter($minify ? '\ScssPhp\ScssPhp\Formatter\Crunched' : '\ScssPhp\ScssPhp\Formatter\Expanded');
$scss_compiler->setOutputStyle($minify ? \ScssPhp\ScssPhp\OutputStyle::COMPRESSED : \ScssPhp\ScssPhp\OutputStyle::EXPANDED);
$scss_compiler->setImportPaths(array(dirname(is_array($source_filename) ? array_first($source_filename) : $source_filename)));
if ($variables)
{

View file

@ -25,25 +25,25 @@ class FormatterTest extends \Codeception\TestCase\Test
public function testMarkdown2HTML()
{
$markdown = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.source.md');
$html1 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target1.html');
$html2 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target2.html');
$html3 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target3.html');
$html4 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target4.html');
$html1 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target1.html'));
$html2 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target2.html'));
$html3 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target3.html'));
$html4 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target4.html'));
$this->assertEquals($html1, Rhymix\Framework\Formatter::markdown2html($markdown));
$this->assertEquals($html2, Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR));
$this->assertEquals($html3, Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR | Rhymix\Framework\Formatter::MD_ENABLE_EXTRA));
$this->assertEquals($html4, Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA));
$this->assertEquals($html1, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown)));
$this->assertEquals($html2, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR)));
$this->assertEquals($html3, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR | Rhymix\Framework\Formatter::MD_ENABLE_EXTRA)));
$this->assertEquals($html4, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA)));
}
public function testMarkdownExtra()
{
$markdown = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.source.md');
$html1 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target1.html');
$html2 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target2.html');
$html1 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target1.html'));
$html2 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target2.html'));
$this->assertEquals($html1, Rhymix\Framework\Formatter::markdown2html($markdown));
$this->assertEquals($html2, Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA));
$this->assertEquals($html1, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown)));
$this->assertEquals($html2, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA)));
}
public function testHTML2Markdown()
@ -202,4 +202,9 @@ class FormatterTest extends \Codeception\TestCase\Test
$target = '!(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 8) || (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 6)';
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
}
protected function _removeSpace($str)
{
return preg_replace('/\s+/', '', $str);
}
}