PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.12
Responsive Menu – Create Mobile-Friendly Menu v3.0.12
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / tests / scssc / ApiTest.php

ApiTest.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.12, at tests/scssc/ApiTest.php

81 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 require_once dirname(dirname(dirname(__FILE__))) . '/src/app/Mappers/scss.inc.php';
4
5 class ApiTest extends PHPUnit_Framework_TestCase
6 {
7 public function setUp()
8 {
9 $this->scss = new scssc_free();
10 }
11
12 public function testUserFunction()
13 {
14 $this->scss->registerFunction("add-two", function ($args) {
15 list($a, $b) = $args;
16 return $a[1] + $b[1];
17 });
18
19 $this->assertEquals(
20 "result: 30;",
21 $this->compile("result: add-two(10, 20);")
22 );
23 }
24
25 public function testImportMissing()
26 {
27 $this->assertEquals(
28 '@import "missing";',
29 $this->compile('@import "missing";')
30 );
31 }
32
33 public function testImportCustomCallback()
34 {
35 $this->scss->addImportPath(function ($path) {
36 return __DIR__ . '/inputs/' . str_replace('.css', '.scss', $path);
37 });
38
39 $this->assertEquals(
40 trim(file_get_contents(__DIR__ . '/outputs/variables.css')),
41 $this->compile('@import "variables.css";')
42 );
43 }
44
45 /**
46 * @dataProvider provideSetVariables
47 */
48 public function testSetVariables($expected, $scss, $variables)
49 {
50 $this->scss->setVariables($variables);
51
52 $this->assertEquals($expected, $this->compile($scss));
53 }
54
55 public function provideSetVariables()
56 {
57 return array(
58 array(
59 ".magic {\n color: red;\n width: 760px; }",
60 '.magic { color: $color; width: $base - 200; }',
61 array(
62 'color' => 'red',
63 'base' => '960px',
64 ),
65 ),
66 array(
67 ".logo {\n color: #808080; }",
68 '.logo { color: desaturate($primary, 100%); }',
69 array(
70 'primary' => '#ff0000',
71 ),
72 ),
73 );
74 }
75
76 public function compile($str)
77 {
78 return trim($this->scss->compile($str));
79 }
80 }
81