Skip to content

RC9 - more tests, improved PHPDoc #64

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

Merged
merged 1 commit into from
Jun 27, 2016
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
2 changes: 2 additions & 0 deletions src/Processor/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use scss_compass as CompassCompiler;

/**
* @see ProcessorTest
*
* @since 0.1
*/
class Processor
Expand Down
5 changes: 5 additions & 0 deletions src/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use Composer\Script\Event;
use EM\CssCompiler\Processor\Processor;

/**
* @see ScriptHandlerTest
*
* @since 0.1
*/
class ScriptHandler
{
const CONFIG_MAIN_KEY = 'css-compiler';
Expand Down
50 changes: 47 additions & 3 deletions tests/phpunit/Processor/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ protected function setUp()
public function attachFiles()
{
$paths = [
static::getSharedFixturesDirectory() . '/less' => 1,
static::getSharedFixturesDirectory() . '/compass' => 1,
static::getSharedFixturesDirectory() . '/scss' => 4,
static::getSharedFixturesDirectory() . '/scss/layout.scss' => 1,
static::getSharedFixturesDirectory() => 6
static::getSharedFixturesDirectory() . '/scss' => 4,
static::getSharedFixturesDirectory() => 7
];
foreach ($paths as $path => $expectedFiles) {
$processor = new Processor($this->io);
Expand Down Expand Up @@ -61,6 +62,15 @@ public function processFileOnSCSS()
$this->invokeProcessFileMethod('scss/layout.scss', '');
}

/**
* @see Processor::processFile
* @test
*/
public function processFileOnLESS()
{
$this->invokeProcessFileMethod('less/print.less', '');
}

/**
* @see Processor::processFile
* @test
Expand Down Expand Up @@ -114,7 +124,7 @@ public function processFileExpectedException()
* @see Processor::getFormatterClass
* @test
*/
public function getFormatterClass()
public function getFormatterClassOnCorrect()
{
foreach (Processor::$supportedFormatters as $formatter) {
$expected = 'Leafo\\ScssPhp\\Formatter\\' . ucfirst($formatter);
Expand All @@ -125,4 +135,38 @@ public function getFormatterClass()
);
}
}

/**
* @see Processor::getFormatterClass
* @test
*
* @expectedException \InvalidArgumentException
*/
public function getFormatterClassOnException()
{
$this->invokeMethod(new Processor($this->io), 'getFormatterClass', ['not-existing']);
}

/**
* @see Processor::fetchInputContextIntoFile
* @test
*/
public function fetchInputContextIntoFileOnSuccess()
{
$file = new FileContainer(static::getSharedFixturesDirectory() . '/scss/layout.scss', '');
$this->invokeMethod(new Processor($this->io), 'fetchInputContextIntoFile', [$file]);

$this->assertNotNull($file->getInputContent());
}

/**
* @see Processor::fetchInputContextIntoFile
* @test
*
* @expectedException \EM\CssCompiler\Exception\FileException
*/
public function fetchInputContextIntoFileOnException()
{
$this->invokeMethod(new Processor($this->io), 'fetchInputContextIntoFile', [new FileContainer('input', 'output')]);
}
}
101 changes: 101 additions & 0 deletions tests/shared-fixtures/less/print.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */

// ==========================================================================
// Print styles.
// Inlined to avoid the additional HTTP request: h5bp.com/r
// ==========================================================================

@media print {
*,
*:before,
*:after {
background: transparent !important;
color: #000 !important; // Black prints faster: h5bp.com/s
box-shadow: none !important;
text-shadow: none !important;
}

a,
a:visited {
text-decoration: underline;
}

a[href]:after {
content: " (" attr(href) ")";
}

abbr[title]:after {
content: " (" attr(title) ")";
}

// Don't show links that are fragment identifiers,
// or use the `javascript:` pseudo protocol
a[href^="#"]:after,
a[href^="javascript:"]:after {
content: "";
}

pre,
blockquote {
border: 1px solid #999;
page-break-inside: avoid;
}

thead {
display: table-header-group; // h5bp.com/t
}

tr,
img {
page-break-inside: avoid;
}

img {
max-width: 100% !important;
}

p,
h2,
h3 {
orphans: 3;
widows: 3;
}

h2,
h3 {
page-break-after: avoid;
}

// Bootstrap specific changes start

// Bootstrap components
.navbar {
display: none;
}
.btn,
.dropup > .btn {
> .caret {
border-top-color: #000 !important;
}
}
.label {
border: 1px solid #000;
}

.table {
border-collapse: collapse !important;

td,
th {
background-color: #fff !important;
}
}
.table-bordered {
th,
td {
border: 1px solid #ddd !important;
}
}

// Bootstrap specific changes end
}