X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/vendor/cssjanus/cssjanus/test/suites/CSSJanusTest.php diff --git a/vendor/cssjanus/cssjanus/test/suites/CSSJanusTest.php b/vendor/cssjanus/cssjanus/test/suites/CSSJanusTest.php new file mode 100644 index 00000000..ad70407b --- /dev/null +++ b/vendor/cssjanus/cssjanus/test/suites/CSSJanusTest.php @@ -0,0 +1,77 @@ + $test) { + if (isset($test['args']) || isset($test['options'])) { + // v1.2.0 test format + $args = isset($test['args']) ? $test['args'] : + (isset($test['options']) ? array( $test['options'] ) : array()); + } else { + // v1.1.x test format + $args = array( + !empty($test['settings']['swapLtrRtlInUrl']), + !empty($test['settings']['swapLeftRightInUrl']) + ); + } + foreach ($test['cases'] as $i => $case) { + $input = $case[0]; + $noop = !isset($case[1]); + $output = $noop ? $input : $case[1]; + + $cases[] = array( + $input, + $args, + $output, + $name, + ); + + if (!$noop) { + // Round trip + $cases[] = array( + $output, + $args, + $input, + $name, + ); + } + } + } + return $cases; + } + + /** + * @dataProvider provideData + */ + public function testTransform($input, $args, $output, $name) { + array_unshift($args, $input); + $this->assertEquals( + $output, + call_user_func_array('CSSJanus::transform', $args), + $name + ); + } + + protected static function getSpec() { + static $json; + if ($json == null) { + $version = '1.2.0'; + $dir = dirname(__DIR__); + $file = "$dir/data-v$version.json"; + if (!is_readable($file)) { + array_map('unlink', glob("$dir/data-v*.json")); + $json = file_get_contents("https://github.com/cssjanus/cssjanus/raw/v$version/test/data.json"); + if ($json === false) { + throw new Exception('Failed to fetch data'); + } + file_put_contents($file, $json); + } else { + $json = file_get_contents($file); + } + } + return json_decode($json, /* $assoc = */ true); + } +}