Skip to content

RC10 - clean test fixtures #68

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 2 commits into from
Jun 30, 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
19 changes: 14 additions & 5 deletions src/Processor/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EM\CssCompiler\Exception\CompilerException;
use EM\CssCompiler\Exception\FileException;
use Leafo\ScssPhp\Compiler as SASSCompiler;
use Leafo\ScssPhp\Exception\ParserException;
use lessc as LESSCompiler;
use scss_compass as CompassCompiler;

Expand Down Expand Up @@ -156,12 +157,20 @@ public function processFile(FileContainer $file)
{
switch ($file->getType()) {
case FileContainer::TYPE_SCSS:
$this->sass->addImportPath(dirname($file->getInputPath()));
$content = $this->sass->compile($file->getInputContent());

return $file->setOutputContent($content);
try {
$this->sass->addImportPath(dirname($file->getInputPath()));
$content = $this->sass->compile($file->getInputContent());

return $file->setOutputContent($content);
} catch (ParserException $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
case FileContainer::TYPE_LESS:
return $file->setOutputContent($this->less->compileFile($file->getInputPath()));
try {
return $file->setOutputContent($this->less->compileFile($file->getInputPath()));
} catch (\Exception $e) {
throw new CompilerException($e->getMessage(), 1, $e);
}
}

throw new CompilerException('unknown compiler');
Expand Down
84 changes: 81 additions & 3 deletions tests/phpunit/Processor/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
*/
class ProcessorTest extends IntegrationTestSuite
{
protected $event;
protected $io;
protected $package;

protected function setUp()
{
Expand All @@ -32,7 +30,7 @@ public function attachFiles()
static::getSharedFixturesDirectory() . '/compass' => 1,
static::getSharedFixturesDirectory() . '/scss/layout.scss' => 1,
static::getSharedFixturesDirectory() . '/scss' => 4,
static::getSharedFixturesDirectory() => 7
static::getSharedFixturesDirectory() => 9
];
foreach ($paths as $path => $expectedFiles) {
$processor = new Processor($this->io);
Expand Down Expand Up @@ -169,4 +167,84 @@ public function fetchInputContextIntoFileOnException()
{
$this->invokeMethod(new Processor($this->io), 'fetchInputContextIntoFile', [new FileContainer('input', 'output')]);
}

/**
* @see Processor::processFiles
* @test
*/
public function processFilesOnSCSS()
{
$this->assertProcessFilesOnValid($this->getSharedFixturesDirectory() . '/scss', '');
}

/**
* @see Processor::processFiles
* @test
*/
public function processFilesOnNotValidSCSS()
{
$this->assertProcessFilesOnNotValid($this->getSharedFixturesDirectory() . '/not-valid-scss', '');
}

/**
* @see Processor::processFiles
* @test
*/
public function processFilesOnLESS()
{
$this->assertProcessFilesOnValid($this->getSharedFixturesDirectory() . '/less', '');
}

/**
* @see Processor::processFiles
* @test
*/
public function processFilesOnNotValidLESS()
{
$this->assertProcessFilesOnNotValid($this->getSharedFixturesDirectory() . '/not-valid-less', '');
}

/**
* @see Processor::processFiles
*
* @param string $input
* @param string $output
*/
private function assertProcessFilesOnValid($input, $output)
{
foreach ($this->processFiles($input, $output) as $file) {
$this->assertNotNull($file->getOutputContent());
}
}

/**
* @see Processor::processFiles
*
* @param string $input
* @param string $output
*/
private function assertProcessFilesOnNotValid($input, $output)
{
foreach ($this->processFiles($input, $output) as $file) {
$this->assertNull($file->getOutputContent());
}
}

/**
* @see Processor::processFiles
*
* @param string $input
* @param string $output
*
* @return FileContainer[]
*/
private function processFiles($input, $output)
{
$processor = new Processor($this->io);

$processor->attachFiles($input, $output);
$processor->processFiles(Processor::FORMATTER_COMPRESSED);

return $processor->getFiles();
}
}
48 changes: 0 additions & 48 deletions tests/shared-fixtures/less/print.less
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/*! 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,
Expand Down Expand Up @@ -45,27 +38,6 @@
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
Expand All @@ -78,24 +50,4 @@
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
}
32 changes: 32 additions & 0 deletions tests/shared-fixtures/not-valid-less/print.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*! 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

//*,
12, // ERROR
*: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) ")";
}
}
3 changes: 3 additions & 0 deletions tests/shared-fixtures/not-valid-scss/game-results.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div#game-results-area table.table {
margin 20px 0; // ERROR
}
1 change: 0 additions & 1 deletion tests/shared-fixtures/scss/game.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

.battlefield-cell-container {
display: flex;

Expand Down
106 changes: 0 additions & 106 deletions tests/shared-fixtures/scss/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,6 @@ body {
}
}

.page-sidebar,
.page-content {
transition: all 0.5s ease;
color: #fff;
}

.page-sidebar {
position: fixed;
height: 100%;
left: 0;
z-index: 1000;
overflow-y: auto;
/*background: linear-gradient(to bottom, #b26cab 0%,#765c8b 100%); !* W3C *!*/
background: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0.5) 50%, rgba(255, 255, 255, 0) 100%);
border-right: 1px solid #fff;
}

.page-sidebar,
.sidebar-nav > li {
width: 250px;
Expand All @@ -60,23 +43,6 @@ body {
}
}

.toggle-btn {
cursor: pointer;
}

.page-header {
font-size: 24px;
margin: 0;
padding: 40px 0 0 20px;

&,
& > span {
line-height: 32px;
height: 75px;
}

}

.sidebar-nav {
list-style-type: none;
padding: 0;
Expand Down Expand Up @@ -107,75 +73,3 @@ body {
cursor: pointer;
}
}

.page-content:not(.toggled) .toggle-btn {
opacity: 0;
}

.page-loading {
background: rgba(2, 2, 2, 0.5);
z-index: 10002;
width: 100%;
height: 100%;
position: absolute;

& > .loading-animation {
margin: auto;
top: 50%;
zoom: 4;
}
}

.no-scroll-mode {
position: fixed;
}

#notification-area {
width: calc(100% - 50px);
border: 1px solid;
min-height: 100px;
position: absolute;
border-radius: 10px;

font-size: 72px;
z-index: 1;
text-align: center;
font-style: italic;
}

#notification-area > .notification-control {
float: right;
margin: 10px;
font-size: 24px;

&:hover {
font-weight: bolder;
cursor: pointer;
}
}

#modal-area {
color: #000;
h4, label {
text-transform: uppercase;
}

.help-block {
font-size: 14px;
font-style: italic;
}
}

.container-fluid {
padding-left: 0;
padding-right: 0;
padding-bottom: 25px;
}

.pagination-area {
text-align: center;
}

a.history-title {
color: #F5DEB3;
}