Repository navigation
Expand file tree
/
Copy pathcssTest.php
More file actions
89 lines (76 loc) · 2.08 KB
/
Copy pathcssTest.php
File metadata and controls
89 lines (76 loc) · 2.08 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
88
89
<?php
require_once __DIR__.'/../minify.php';
require_once __DIR__.'/../css.php';
require_once __DIR__.'/../exception.php';
require_once 'PHPUnit/Framework/TestCase.php';
use MatthiasMullie\Minify;
/**
* CSS minifier test case.
*/
class CSSTest extends PHPUnit_Framework_TestCase
{
private $minifier;
/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
parent::setUp();
$this->minifier = new Minify\CSS();
}
/**
* Cleans up the environment after running a test.
*/
protected function tearDown()
{
$this->minifier = null;
parent::tearDown();
}
/**
* Test CSS minifier rules, provided by dataProvider
*
* @test
* @dataProvider dataProvider
*/
public function failure($input, $expected, $options)
{
$this->minifier->add($input);
$result = $this->minifier->minify(false, $options);
$this->assertEquals($result, $expected);
}
/**
* Test cases [input, expected result, options]
*
* @return array
*/
public function dataProvider()
{
$tests = array();
$tests[] = array(
__DIR__.'/sample/css/combine_imports/index.css',
file_get_contents(__DIR__.'/sample/css/combine_imports/import.css')."\n",
Minify\CSS::COMBINE_IMPORTS
);
$tests[] = array(
'color: #FF00FF;',
'color: #F0F;',
Minify\CSS::SHORTEN_HEX
);
$tests[] = array(
__DIR__.'/sample/css/import_files/index.css',
'background: url(data:image/png;base64,'.base64_encode(file_get_contents(__DIR__.'/sample/css/import_files/file.png')).');'."\n",
Minify\CSS::IMPORT_FILES
);
$tests[] = array(
'/* This is a CSS comment */',
'',
Minify\CSS::STRIP_COMMENTS
);
$tests[] = array(
'body { color: red; }',
'body{color:red}',
Minify\CSS::STRIP_WHITESPACE
);
return $tests;
}
}