Skip to content

Commit

Permalink
Adds some SassTask tests (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejlew authored and mrook committed Mar 26, 2018
1 parent 74405e4 commit dbf60ab
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"siad007/versioncontrol_hg": "A library for interfacing with Mercurial repositories.",
"tedivm/jshrink": "Javascript Minifier built in PHP",
"symfony/stopwatch": "Needed by the StopwatchTask",
"aws/aws-sdk-php": "AWS SDK used by S3*Tasks"
"aws/aws-sdk-php": "AWS SDK used by S3*Tasks",
"leafo/scssphp": "A compiler for SCSS written in PHP, used by SassTask"
}
}
40 changes: 39 additions & 1 deletion test/classes/phing/tasks/ext/SassTask/SassTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
class SassTaskTest extends BuildFileTest
{

private const SASS_TEST_BASE = PHING_TEST_BASE . "/etc/tasks/ext/sass/";

/** @var FileSystem */
private $fs;

/** @var SassTask */
private $object;

Expand All @@ -11,9 +16,24 @@ class SassTaskTest extends BuildFileTest

public function setUp(): void
{
$this->configureProject(PHING_TEST_BASE . "/etc/tasks/ext/SassTaskTest.xml");
$this->configureProject(self::SASS_TEST_BASE . "SassTaskTest.xml");
$this->object = new SassTask();
$this->sassTaskAssert = new SassTaskAssert();
$this->fs = FileSystem::getFileSystem();
}

public function tearDown(): void
{
parent::tearDown();
if (file_exists(self::SASS_TEST_BASE . "test.css")) {
$this->fs->unlink(self::SASS_TEST_BASE . "test.css");
}
if (file_exists(self::SASS_TEST_BASE . "test.css.map")) {
$this->fs->unlink(self::SASS_TEST_BASE . "test.css.map");
}
if (is_dir(self::SASS_TEST_BASE . ".sass-cache")) {
$this->fs->rmdir(self::SASS_TEST_BASE . ".sass-cache", true);
}
}

public function testCheckDefaults(): void
Expand Down Expand Up @@ -76,4 +96,22 @@ public function testNoFilesetAndNoFileSet(): void
"Missing either a nested fileset or attribute 'file'"
);
}

public function testItCompilesWithSass(): void
{
if (!$this->fs->which('sass')) {
$this->markTestSkipped('Sass not found');
}
$this->executeTarget("testItCompilesWithSass");
$this->assertTrue(file_exists(self::SASS_TEST_BASE . "test.css"));
}

public function testItCompilesWithScssPhp(): void
{
if (!class_exists('\Leafo\ScssPhp\Compiler')) {
$this->markTestSkipped('ScssPhp not found');
}
$this->executeTarget("testItCompilesWithScssPhp");
$this->assertTrue(file_exists(self::SASS_TEST_BASE . "test.css"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,17 @@
<target name="testNoFilesetAndNoFileSet">
<sass useSass="no" useScssphp="no"/>
</target>

<target name="testItCompilesWithSass">
<sass outputpath="." style="compacted" useSass="yes">
<fileset dir="."/>
</sass>
</target>

<target name="testItCompilesWithScssPhp">
<sass outputpath="." style="compacted" useScssphp="yes">
<fileset dir="."/>
</sass>
</target>

</project>
4 changes: 4 additions & 0 deletions test/etc/tasks/ext/sass/test.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$primaryColor: #000

body
background: $primaryColor

0 comments on commit dbf60ab

Please sign in to comment.