PluginProbe
GetResponse Forms by Optin Cat / 1.3.4
GetResponse Forms by Optin Cat v1.3.4
1.3.4 1.3.5 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 2.0.0 All 36 releases
getresponse / includes / classes / scssphp / tests / InputTest.php

InputTest.php in GetResponse Forms by Optin Cat 1.3.4, at includes/classes/scssphp/tests/InputTest.php

99 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leafo\ScssPhp\Tests;
4
5 use Leafo\ScssPhp\Compiler;
6
7 // Runs all the tests in inputs/ and compares their output to ouputs/
8
9 function _dump($value)
10 {
11 fwrite(STDOUT, print_r($value, true));
12 }
13
14 function _quote($str)
15 {
16 return preg_quote($str, '/');
17 }
18
19 class InputTest extends \PHPUnit_Framework_TestCase
20 {
21 protected static $inputDir = 'inputs';
22 protected static $outputDir = 'outputs';
23
24 public function setUp()
25 {
26 $this->scss = new Compiler();
27 $this->scss->addImportPath(__DIR__ . '/' . self::$inputDir);
28 }
29
30 /**
31 * @dataProvider fileNameProvider
32 */
33 public function testInputFile($inFname, $outFname)
34 {
35 if (getenv('BUILD')) {
36 return $this->buildInput($inFname, $outFname);
37 }
38
39 if (!is_readable($outFname)) {
40 $this->fail("$outFname is missing, consider building tests with BUILD=true");
41 }
42
43 $input = file_get_contents($inFname);
44 $output = file_get_contents($outFname);
45
46 $this->assertEquals($output, $this->scss->compile($input));
47 }
48
49 public function fileNameProvider()
50 {
51 return array_map(
52 function ($a) {
53 return array($a, InputTest::outputNameFor($a));
54 },
55 self::findInputNames()
56 );
57 }
58
59 // only run when env is set
60 public function buildInput($inFname, $outFname)
61 {
62 $css = $this->scss->compile(file_get_contents($inFname));
63 file_put_contents($outFname, $css);
64 }
65
66 public static function findInputNames($pattern = '*')
67 {
68 $files = glob(__DIR__ . '/' . self::$inputDir . '/' . $pattern);
69 $files = array_filter($files, 'is_file');
70 if ($pattern = getenv('MATCH')) {
71 $files = array_filter($files, function ($fname) use ($pattern) {
72 return preg_match("/$pattern/", $fname);
73 });
74 }
75
76 return $files;
77 }
78
79 public static function outputNameFor($input)
80 {
81 $front = _quote(__DIR__ . '/');
82 $out = preg_replace("/^$front/", '', $input);
83
84 $in = _quote(self::$inputDir . '/');
85 $out = preg_replace("/$in/", self::$outputDir . '/', $out);
86 $out = preg_replace("/.scss$/", '.css', $out);
87
88 return __DIR__ . '/' . $out;
89 }
90
91 public static function buildTests($pattern)
92 {
93 $files = self::findInputNames($pattern);
94
95 foreach ($files as $file) {
96 }
97 }
98 }
99