Skip to content

Commit e9d56c5

Browse files
Merge branch 'more_tests' into refactoring_file_container
2 parents 433e08a + 51eb653 commit e9d56c5

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

tests/phpunit/Container/File.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace EM\CssCompiler\Container;
4+
5+
class FileContainerTest
6+
{
7+
}
+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
namespace EM\Tests\PHPUnit\Processor;
4+
5+
use Composer\IO\IOInterface;
6+
use EM\CssCompiler\Container\FileContainer;
7+
use EM\CssCompiler\Processor\Processor;
8+
use EM\Tests\Environment\IntegrationTestSuite;
9+
10+
/**
11+
* @see Processor
12+
*/
13+
class ProcessorTest extends IntegrationTestSuite
14+
{
15+
protected $event;
16+
protected $io;
17+
protected $package;
18+
19+
protected function setUp()
20+
{
21+
$this->io = $this->getMockBuilder(IOInterface::class)->getMock();
22+
}
23+
24+
/**
25+
* @see Processor::attachFiles
26+
* @test
27+
*/
28+
public function attachFiles()
29+
{
30+
$paths = [
31+
static::getSharedFixturesDirectory() . '/sass',
32+
static::getSharedFixturesDirectory() . '/compass'
33+
];
34+
$cacheDir = dirname(dirname(__DIR__)) . '/var/cache';
35+
36+
foreach ($paths as $path) {
37+
$processor = new Processor($this->io);
38+
$processor->attachFiles($path, $cacheDir);
39+
40+
$this->assertCount(2, $processor->getFiles());
41+
}
42+
}
43+
44+
/**
45+
* @see Processor::attachFiles
46+
* @test
47+
*
48+
* @expectedException \Exception
49+
*/
50+
public function attachFilesExpectedException()
51+
{
52+
$path = static::getSharedFixturesDirectory() . '/do-not-exists';
53+
$cacheDir = dirname(dirname(__DIR__)) . '/var/cache';
54+
55+
$processor = new Processor($this->io);
56+
$processor->attachFiles($path, $cacheDir);
57+
58+
$this->assertCount(2, $processor->getFiles());
59+
}
60+
61+
/**
62+
* @see Processor::processFile
63+
* @test
64+
*/
65+
public function processFileSASS()
66+
{
67+
$file = (new FileContainer(static::getSharedFixturesDirectory() . '/compass/sass/layout.scss', ''))
68+
->setSourceContentFromSourcePath();
69+
70+
(new Processor($this->io))->processFile($file);
71+
72+
$this->assertNotEquals($file->getParsedContent(), $file->getSourceContent());
73+
}
74+
75+
/**
76+
* @see Processor::processFile
77+
* @test
78+
*
79+
* @expectedException \EM\CssCompiler\Exception\CompilerException
80+
*/
81+
public function processFileExpectedException()
82+
{
83+
$file = (new FileContainer(static::getSharedFixturesDirectory() . '/compass/sass/', ''))
84+
->setSourceContentFromSourcePath()
85+
->setType(FileContainer::TYPE_UNKNOWN);
86+
87+
(new Processor($this->io))->processFile($file);
88+
}
89+
90+
/**
91+
* @see Processor::getFormatterClass
92+
* @test
93+
*/
94+
public function getFormatterClass()
95+
{
96+
foreach (Processor::$supportedFormatters as $formatter) {
97+
$expected = 'Leafo\\ScssPhp\\Formatter\\' . ucfirst($formatter);
98+
99+
$this->assertEquals(
100+
$expected,
101+
$this->invokeMethod(new Processor($this->io), 'getFormatterClass', [$formatter])
102+
);
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)