forked from leafo/scssphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiTest.php
More file actions
41 lines (32 loc) · 931 Bytes
/
ApiTest.php
File metadata and controls
41 lines (32 loc) · 931 Bytes
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
<?php
require_once __DIR__ . "/../scss.inc.php";
class ApiTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->scss = new scssc();
}
public function testUserFunction() {
$this->scss->registerFunction("add-two", function($args) {
list($a, $b) = $args;
return $a[1] + $b[1];
});
$this->assertEquals(
"result: 30;",
$this->compile("result: add-two(10, 20);"));
}
public function testImportMissing(){
$this->assertEquals(
'@import "missing";',
$this->compile('@import "missing";'));
}
public function testImportCustomCallback(){
$this->scss->addImportPath(function($path) {
return __DIR__.'/inputs/' . str_replace('.css','.scss',$path);
});
$this->assertEquals(
trim(file_get_contents(__DIR__.'/outputs/variables.css')),
$this->compile('@import "variables.css";'));
}
public function compile($str) {
return trim($this->scss->compile($str));
}
}