-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathCompressedTest.php
More file actions
87 lines (73 loc) · 2.29 KB
/
CompressedTest.php
File metadata and controls
87 lines (73 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* SCSSPHP
*
* @copyright 2012-2020 Leaf Corcoran
*
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://scssphp.github.io/scssphp
*/
namespace ScssPhp\ScssPhp\Tests;
use PHPUnit\Framework\TestCase;
use ScssPhp\ScssPhp\Compiler;
use ScssPhp\ScssPhp\OutputStyle;
class CompressedTest extends TestCase
{
public function testRemovesUnnecessaryWhitespaceAndSemicolons()
{
$this->assertEquals('a{x:y}', $this->compile('a {x: y}'));
}
public function testForDeclarationsPreservesSemicolonsWhenNecessary()
{
$this->assertEquals('a{q:r;s:t}', $this->compile('a {q: r; s: t}'));
}
public function testTheTopLevelRemovesWhitespaceAndSemicolonsBetweenAtRules()
{
$this->assertEquals('@foo;@bar;@baz', $this->compile('@foo; @bar; @baz;'));
}
public function testTheTopLevelRemovesWhitespaceAndSemicolonsBetweenStyleRules()
{
$this->assertEquals('a{b:c}x{y:z}', $this->compile('a {b: c} x {y: z}'));
}
public function testKeyframesRemovesWhitespaceAfterTheSelector()
{
$this->assertEquals('@keyframes a{from{a:b}}', $this->compile('@keyframes a {from {a: b}}'));
}
public function testKeyframesRemovesWhitespaceAfterCommas()
{
$this->assertEquals('@keyframes a{from,to{a:b}}', $this->compile('@keyframes a {from, to {a: b}}'));
}
public function testCommentsAreRemoved()
{
$this->assertEquals('', $this->compile('/* foo bar */'));
$this->assertEquals('a{b:c;d:e}', $this->compile('a {
b: c;
/* foo bar */
d: e;
}'));
}
/**
* @testdox Comments are preserved with /*!
*/
public function testCommentsArePreserved()
{
$this->assertEquals('/*! foo bar */', $this->compile('/*! foo bar */'));
$this->assertEquals('/*! foo *//*! bar */', $this->compile("/*! foo */\n/*! bar */"));
$this->assertEquals('a{/*! foo bar */}', $this->compile('a {
/*! foo bar */
}'));
}
/**
* @param string $input
*
* @return string
*/
private function compile($input)
{
$compiler = new Compiler();
$compiler->setOutputStyle(OutputStyle::COMPRESSED);
$result = $compiler->compileString($input);
return $result->getCss();
}
}