Skip to content

Commit 5204cbd

Browse files
author
Eugene Matvejev
authored
Merge pull request #64 from eugene-matvejev/additional_tests
RC9 - more tests, improved PHPDoc
2 parents 86642f6 + 894918f commit 5204cbd

File tree

4 files changed

+155
-3
lines changed

4 files changed

+155
-3
lines changed

src/Processor/Processor.php

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use scss_compass as CompassCompiler;
1212

1313
/**
14+
* @see ProcessorTest
15+
*
1416
* @since 0.1
1517
*/
1618
class Processor

src/ScriptHandler.php

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
use Composer\Script\Event;
66
use EM\CssCompiler\Processor\Processor;
77

8+
/**
9+
* @see ScriptHandlerTest
10+
*
11+
* @since 0.1
12+
*/
813
class ScriptHandler
914
{
1015
const CONFIG_MAIN_KEY = 'css-compiler';

tests/phpunit/Processor/ProcessorTest.php

+47-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ protected function setUp()
2828
public function attachFiles()
2929
{
3030
$paths = [
31+
static::getSharedFixturesDirectory() . '/less' => 1,
3132
static::getSharedFixturesDirectory() . '/compass' => 1,
32-
static::getSharedFixturesDirectory() . '/scss' => 4,
3333
static::getSharedFixturesDirectory() . '/scss/layout.scss' => 1,
34-
static::getSharedFixturesDirectory() => 6
34+
static::getSharedFixturesDirectory() . '/scss' => 4,
35+
static::getSharedFixturesDirectory() => 7
3536
];
3637
foreach ($paths as $path => $expectedFiles) {
3738
$processor = new Processor($this->io);
@@ -61,6 +62,15 @@ public function processFileOnSCSS()
6162
$this->invokeProcessFileMethod('scss/layout.scss', '');
6263
}
6364

65+
/**
66+
* @see Processor::processFile
67+
* @test
68+
*/
69+
public function processFileOnLESS()
70+
{
71+
$this->invokeProcessFileMethod('less/print.less', '');
72+
}
73+
6474
/**
6575
* @see Processor::processFile
6676
* @test
@@ -114,7 +124,7 @@ public function processFileExpectedException()
114124
* @see Processor::getFormatterClass
115125
* @test
116126
*/
117-
public function getFormatterClass()
127+
public function getFormatterClassOnCorrect()
118128
{
119129
foreach (Processor::$supportedFormatters as $formatter) {
120130
$expected = 'Leafo\\ScssPhp\\Formatter\\' . ucfirst($formatter);
@@ -125,4 +135,38 @@ public function getFormatterClass()
125135
);
126136
}
127137
}
138+
139+
/**
140+
* @see Processor::getFormatterClass
141+
* @test
142+
*
143+
* @expectedException \InvalidArgumentException
144+
*/
145+
public function getFormatterClassOnException()
146+
{
147+
$this->invokeMethod(new Processor($this->io), 'getFormatterClass', ['not-existing']);
148+
}
149+
150+
/**
151+
* @see Processor::fetchInputContextIntoFile
152+
* @test
153+
*/
154+
public function fetchInputContextIntoFileOnSuccess()
155+
{
156+
$file = new FileContainer(static::getSharedFixturesDirectory() . '/scss/layout.scss', '');
157+
$this->invokeMethod(new Processor($this->io), 'fetchInputContextIntoFile', [$file]);
158+
159+
$this->assertNotNull($file->getInputContent());
160+
}
161+
162+
/**
163+
* @see Processor::fetchInputContextIntoFile
164+
* @test
165+
*
166+
* @expectedException \EM\CssCompiler\Exception\FileException
167+
*/
168+
public function fetchInputContextIntoFileOnException()
169+
{
170+
$this->invokeMethod(new Processor($this->io), 'fetchInputContextIntoFile', [new FileContainer('input', 'output')]);
171+
}
128172
}

tests/shared-fixtures/less/print.less

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */
2+
3+
// ==========================================================================
4+
// Print styles.
5+
// Inlined to avoid the additional HTTP request: h5bp.com/r
6+
// ==========================================================================
7+
8+
@media print {
9+
*,
10+
*:before,
11+
*:after {
12+
background: transparent !important;
13+
color: #000 !important; // Black prints faster: h5bp.com/s
14+
box-shadow: none !important;
15+
text-shadow: none !important;
16+
}
17+
18+
a,
19+
a:visited {
20+
text-decoration: underline;
21+
}
22+
23+
a[href]:after {
24+
content: " (" attr(href) ")";
25+
}
26+
27+
abbr[title]:after {
28+
content: " (" attr(title) ")";
29+
}
30+
31+
// Don't show links that are fragment identifiers,
32+
// or use the `javascript:` pseudo protocol
33+
a[href^="#"]:after,
34+
a[href^="javascript:"]:after {
35+
content: "";
36+
}
37+
38+
pre,
39+
blockquote {
40+
border: 1px solid #999;
41+
page-break-inside: avoid;
42+
}
43+
44+
thead {
45+
display: table-header-group; // h5bp.com/t
46+
}
47+
48+
tr,
49+
img {
50+
page-break-inside: avoid;
51+
}
52+
53+
img {
54+
max-width: 100% !important;
55+
}
56+
57+
p,
58+
h2,
59+
h3 {
60+
orphans: 3;
61+
widows: 3;
62+
}
63+
64+
h2,
65+
h3 {
66+
page-break-after: avoid;
67+
}
68+
69+
// Bootstrap specific changes start
70+
71+
// Bootstrap components
72+
.navbar {
73+
display: none;
74+
}
75+
.btn,
76+
.dropup > .btn {
77+
> .caret {
78+
border-top-color: #000 !important;
79+
}
80+
}
81+
.label {
82+
border: 1px solid #000;
83+
}
84+
85+
.table {
86+
border-collapse: collapse !important;
87+
88+
td,
89+
th {
90+
background-color: #fff !important;
91+
}
92+
}
93+
.table-bordered {
94+
th,
95+
td {
96+
border: 1px solid #ddd !important;
97+
}
98+
}
99+
100+
// Bootstrap specific changes end
101+
}

0 commit comments

Comments
 (0)