Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SassTask tests #882

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/classes/phing/tasks/ext/SassTask/SassTaskAssert.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\Assert;

class SassTaskAssert extends Assert
{

public function assertDefaults(SassTask $task): void
{
$this->assertEquals('', $task->getPath());
$this->assertEquals('', $task->getOutputpath());
$this->assertEquals('utf-8', $task->getEncoding());
$this->assertEquals('nested', $task->getStyle());
$this->assertEquals('css', $task->getNewext());
$this->assertFalse($task->getTrace());
$this->assertFalse($task->getCheck());
$this->assertTrue($task->getUnixnewlines());
$this->assertTrue($task->getKeepsubdirectories());
$this->assertTrue($task->getRemoveoldext());
$this->assertEquals('sass', $task->getExecutable(), "Executable is not 'sass'");
$this->assertEquals('', $task->getExtfilter(), "Extfilter is not ''");
$this->assertTrue($task->getRemoveoldext());
$this->assertFalse($task->getCompressed());
$this->assertFalse($task->getCompact());
$this->assertFalse($task->getExpand());
$this->assertFalse($task->getCrunched());
$this->assertTrue($task->getNested());
}

public function assertCompactStyle(SassTask $task): void
{
$this->assertTrue($task->getCompact());
$this->assertEquals('compact', $task->getStyle());
$this->assertEquals('--style compact', $task->getFlags());
$this->assertFalse($task->getCompressed());
$this->assertFalse($task->getExpand());
$this->assertFalse($task->getCrunched());
$this->assertFalse($task->getNested());
}

public function assertCompressedStyle(SassTask $task): void
{
$this->assertTrue($task->getCompressed());
$this->assertEquals('compressed', $task->getStyle());
$this->assertEquals('--style compressed', $task->getFlags());
$this->assertFalse($task->getCompact());
$this->assertFalse($task->getExpand());
$this->assertFalse($task->getCrunched());
$this->assertFalse($task->getNested());
}
}
79 changes: 79 additions & 0 deletions test/classes/phing/tasks/ext/SassTask/SassTaskTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

class SassTaskTest extends BuildFileTest
{

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

/** @var SassTaskAssert */
private $sassTaskAssert;

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

public function testCheckDefaults(): void
{
$this->sassTaskAssert->assertDefaults($this->object);
}

public function testSetStyleCompactViaSetStyle(): void
{
$this->object->setStyle('crunched');
$this->object->setStyle('compact');
$this->sassTaskAssert->assertCompactStyle($this->object);
}

public function testSetStyleCompactViaOwnMethod(): void
{
$this->object->setStyle('crunched');
$this->object->setCompact('yes');
$this->sassTaskAssert->assertCompactStyle($this->object);
}

public function testSetStyleCompressedViaSetStyle(): void
{
$this->object->setStyle('crunched');
$this->object->setStyle('compressed');
$this->sassTaskAssert->assertCompressedStyle($this->object);
}

public function testSetStyleCompressedViaOwnMethod(): void
{
$this->object->setStyle('crunched');
$this->object->setCompressed('yes');
$this->sassTaskAssert->assertCompressedStyle($this->object);
}

public function testNothing(): void
{
$this->executeTarget("nothing");
$this->assertInLogs(
"Neither sass nor scssphp are to be used.",
Project::MSG_ERR
);
}

public function testSetStyleToUnrecognised(): void
{
$this->executeTarget("testSettingUnrecognisedStyle");
$this->assertInLogs('Style compacted ignored', Project::MSG_INFO);
$this->assertInLogs(
"Neither sass nor scssphp are to be used.",
Project::MSG_ERR
);
}

public function testNoFilesetAndNoFileSet(): void
{
$this->expectBuildExceptionContaining(
'testNoFilesetAndNoFileSet',
'testNoFilesetAndNoFileSet',
"Missing either a nested fileset or attribute 'file'"
);
}
}
122 changes: 0 additions & 122 deletions test/classes/phing/tasks/ext/SassTaskTest.php

This file was deleted.