diff --git a/src/Processor/Processor.php b/src/Processor/Processor.php index 17dec43..86915cf 100644 --- a/src/Processor/Processor.php +++ b/src/Processor/Processor.php @@ -11,6 +11,8 @@ use scss_compass as CompassCompiler; /** + * @see ProcessorTest + * * @since 0.1 */ class Processor diff --git a/src/ScriptHandler.php b/src/ScriptHandler.php index 3f204bb..d18fd87 100644 --- a/src/ScriptHandler.php +++ b/src/ScriptHandler.php @@ -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'; diff --git a/tests/phpunit/Processor/ProcessorTest.php b/tests/phpunit/Processor/ProcessorTest.php index 47425a5..64a7f9a 100644 --- a/tests/phpunit/Processor/ProcessorTest.php +++ b/tests/phpunit/Processor/ProcessorTest.php @@ -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); @@ -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 @@ -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); @@ -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')]); + } } diff --git a/tests/shared-fixtures/less/print.less b/tests/shared-fixtures/less/print.less new file mode 100644 index 0000000..66e54ab --- /dev/null +++ b/tests/shared-fixtures/less/print.less @@ -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 +}