From b8168a0c4375c1b5919c072eac32d4a355bbcabe Mon Sep 17 00:00:00 2001 From: Andrew Tch Date: Wed, 13 Jan 2016 10:12:49 +0200 Subject: [PATCH 1/3] initial push for testing compatibility --- src/Assetic/Filter/Sass/BaseSassFilter.php | 4 +-- src/Assetic/Util/CssUtils.php | 2 +- src/Assetic/Util/SassUtils.php | 22 ++++++++++++ .../Assetic/Test/Filter/ScssphpFilterTest.php | 4 +-- tests/Assetic/Test/Util/SassUtilsTest.php | 36 +++++++++++++++++++ 5 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 src/Assetic/Util/SassUtils.php create mode 100644 tests/Assetic/Test/Util/SassUtilsTest.php diff --git a/src/Assetic/Filter/Sass/BaseSassFilter.php b/src/Assetic/Filter/Sass/BaseSassFilter.php index 65479eb9b..68903f0ef 100644 --- a/src/Assetic/Filter/Sass/BaseSassFilter.php +++ b/src/Assetic/Filter/Sass/BaseSassFilter.php @@ -6,7 +6,7 @@ use Assetic\Factory\AssetFactory; use Assetic\Filter\BaseProcessFilter; use Assetic\Filter\DependencyExtractorInterface; -use Assetic\Util\CssUtils; +use Assetic\Util\SassUtils; abstract class BaseSassFilter extends BaseProcessFilter implements DependencyExtractorInterface { @@ -34,7 +34,7 @@ public function getChildren(AssetFactory $factory, $content, $loadPath = null) } $children = array(); - foreach (CssUtils::extractImports($content) as $reference) { + foreach (SassUtils::extractImports($content) as $reference) { if ('.css' === substr($reference, -4)) { // skip normal css imports // todo: skip imports with media queries diff --git a/src/Assetic/Util/CssUtils.php b/src/Assetic/Util/CssUtils.php index ac043fd11..ebc44b031 100644 --- a/src/Assetic/Util/CssUtils.php +++ b/src/Assetic/Util/CssUtils.php @@ -129,7 +129,7 @@ public static function extractImports($content) $imports[] = $matches['url']; }); - return array_unique($imports); + return array_unique(array_filter($imports)); } final private function __construct() diff --git a/src/Assetic/Util/SassUtils.php b/src/Assetic/Util/SassUtils.php new file mode 100644 index 000000000..f65ed3870 --- /dev/null +++ b/src/Assetic/Util/SassUtils.php @@ -0,0 +1,22 @@ + + */ +abstract class SassUtils extends CssUtils +{ + const REGEX_COMMENTS = '/((?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)|\/\/[^\n]+)/'; +} diff --git a/tests/Assetic/Test/Filter/ScssphpFilterTest.php b/tests/Assetic/Test/Filter/ScssphpFilterTest.php index e7aec7adb..fe3f1d40c 100644 --- a/tests/Assetic/Test/Filter/ScssphpFilterTest.php +++ b/tests/Assetic/Test/Filter/ScssphpFilterTest.php @@ -90,9 +90,9 @@ public function testCompassExtensionCanBeEnabled() public function testCompassExtensionCanBeDisabled() { - $this->setExpectedExceptionRegExp( + $this->setExpectedException( 'Exception', - '/Undefined mixin box\-shadow\: failed at `@include box\-shadow\(10px 10px 8px red\);`.*? line:? 4/' + 'Undefined mixin box-shadow: line: 4' ); $asset = new FileAsset(__DIR__.'/fixtures/sass/main_compass.scss'); diff --git a/tests/Assetic/Test/Util/SassUtilsTest.php b/tests/Assetic/Test/Util/SassUtilsTest.php new file mode 100644 index 000000000..efd9c8780 --- /dev/null +++ b/tests/Assetic/Test/Util/SassUtilsTest.php @@ -0,0 +1,36 @@ +assertEquals($expected, array_intersect($expected, $actual), '::extractImports() returns all expected URLs'); + $this->assertEquals(array(), array_diff($actual, $expected), '::extractImports() does not return unexpected URLs'); + } +} From 096d931564db83c190a085df5a1fd8c015e6ab47 Mon Sep 17 00:00:00 2001 From: Andrew Tch Date: Wed, 13 Jan 2016 11:25:39 +0200 Subject: [PATCH 2/3] fixed (probably) different versions of error messages for scssphp --- tests/Assetic/Test/Filter/ScssphpFilterTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Assetic/Test/Filter/ScssphpFilterTest.php b/tests/Assetic/Test/Filter/ScssphpFilterTest.php index fe3f1d40c..6d93d07d5 100644 --- a/tests/Assetic/Test/Filter/ScssphpFilterTest.php +++ b/tests/Assetic/Test/Filter/ScssphpFilterTest.php @@ -90,9 +90,9 @@ public function testCompassExtensionCanBeEnabled() public function testCompassExtensionCanBeDisabled() { - $this->setExpectedException( + $this->setExpectedExceptionRegExp( 'Exception', - 'Undefined mixin box-shadow: line: 4' + '/^Undefined mixin box-shadow:.*line:* 4$/' ); $asset = new FileAsset(__DIR__.'/fixtures/sass/main_compass.scss'); From 291fb39105fb07215aa39e2db6d8ab63ab02af99 Mon Sep 17 00:00:00 2001 From: Andrew Tch Date: Wed, 13 Jan 2016 12:04:00 +0200 Subject: [PATCH 3/3] removed extra spaces --- src/Assetic/Util/SassUtils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Assetic/Util/SassUtils.php b/src/Assetic/Util/SassUtils.php index f65ed3870..9c076152d 100644 --- a/src/Assetic/Util/SassUtils.php +++ b/src/Assetic/Util/SassUtils.php @@ -18,5 +18,5 @@ */ abstract class SassUtils extends CssUtils { - const REGEX_COMMENTS = '/((?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)|\/\/[^\n]+)/'; + const REGEX_COMMENTS = '/((?:\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)|\/\/[^\n]+)/'; }