PluginProbe
GetResponse Forms by Optin Cat / 1.3.5
GetResponse Forms by Optin Cat v1.3.5
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-0.0.15 / tests / InputTest.php

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

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