mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-18 18:59:56 +09:00
Fix #1927 string * float error in leafo/lessphp
- dev-master 태그로 업데이트
- PHP 8.0 이상 버전에서 오류를 일으키는 {0} 문법 4군데 재수정
This commit is contained in:
parent
e258cf7525
commit
1f9056fc08
31 changed files with 4558 additions and 4326 deletions
123
vendor/leafo/lessphp/tests/InputTest.php
vendored
123
vendor/leafo/lessphp/tests/InputTest.php
vendored
|
|
@ -5,85 +5,86 @@ require_once __DIR__ . "/../lessc.inc.php";
|
|||
// Runs all the tests in inputs/ and compares their output to ouputs/
|
||||
|
||||
function _dump($value) {
|
||||
fwrite(STDOUT, print_r($value, true));
|
||||
fwrite(STDOUT, print_r($value, true));
|
||||
}
|
||||
|
||||
function _quote($str) {
|
||||
return preg_quote($str, "/");
|
||||
return preg_quote($str, "/");
|
||||
}
|
||||
|
||||
class InputTest extends PHPUnit_Framework_TestCase {
|
||||
protected static $importDirs = array("inputs/test-imports");
|
||||
class InputTest extends PHPUnit\Framework\TestCase {
|
||||
protected static $importDirs = array("inputs/test-imports");
|
||||
|
||||
protected static $testDirs = array(
|
||||
"inputs" => "outputs",
|
||||
"inputs_lessjs" => "outputs_lessjs",
|
||||
);
|
||||
protected static $testDirs = array(
|
||||
"inputs" => "outputs",
|
||||
"inputs_lessjs" => "outputs_lessjs",
|
||||
);
|
||||
|
||||
public function setUp() {
|
||||
$this->less = new lessc();
|
||||
$this->less->importDir = array_map(function($path) {
|
||||
return __DIR__ . "/" . $path;
|
||||
}, self::$importDirs);
|
||||
}
|
||||
public function setUp() {
|
||||
$this->less = new lessc();
|
||||
$this->less->importDir = array_map(function($path) {
|
||||
return __DIR__ . "/" . $path;
|
||||
}, self::$importDirs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fileNameProvider
|
||||
*/
|
||||
public function testInputFile($inFname) {
|
||||
if ($pattern = getenv("BUILD")) {
|
||||
return $this->buildInput($inFname);
|
||||
}
|
||||
/**
|
||||
* @dataProvider fileNameProvider
|
||||
*/
|
||||
public function testInputFile($inFname) {
|
||||
if ($pattern = getenv("BUILD")) {
|
||||
return $this->buildInput($inFname);
|
||||
}
|
||||
|
||||
$outFname = self::outputNameFor($inFname);
|
||||
$outFname = self::outputNameFor($inFname);
|
||||
|
||||
if (!is_readable($outFname)) {
|
||||
$this->fail("$outFname is missing, ".
|
||||
"consider building tests with BUILD=true");
|
||||
}
|
||||
if (!is_readable($outFname)) {
|
||||
$this->fail("$outFname is missing, ".
|
||||
"consider building tests with BUILD=true");
|
||||
}
|
||||
|
||||
$input = file_get_contents($inFname);
|
||||
$output = file_get_contents($outFname);
|
||||
$input = file_get_contents($inFname);
|
||||
$output = file_get_contents($outFname);
|
||||
|
||||
$this->assertEquals($output, $this->less->parse($input));
|
||||
}
|
||||
$this->assertEquals($output, $this->less->parse($input));
|
||||
}
|
||||
|
||||
public function fileNameProvider() {
|
||||
return array_map(function($a) { return array($a); },
|
||||
self::findInputNames());
|
||||
}
|
||||
public function fileNameProvider() {
|
||||
return array_map(
|
||||
function($a) { return array($a); },
|
||||
self::findInputNames()
|
||||
);
|
||||
}
|
||||
|
||||
// only run when env is set
|
||||
public function buildInput($inFname) {
|
||||
$css = $this->less->parse(file_get_contents($inFname));
|
||||
file_put_contents(self::outputNameFor($inFname), $css);
|
||||
}
|
||||
// only run when env is set
|
||||
public function buildInput($inFname) {
|
||||
$css = $this->less->parse(file_get_contents($inFname));
|
||||
file_put_contents(self::outputNameFor($inFname), $css);
|
||||
}
|
||||
|
||||
static public function findInputNames($pattern="*.less") {
|
||||
$files = array();
|
||||
foreach (self::$testDirs as $inputDir => $outputDir) {
|
||||
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
|
||||
}
|
||||
public static function findInputNames($pattern="*.less") {
|
||||
$files = array();
|
||||
foreach (self::$testDirs as $inputDir => $outputDir) {
|
||||
$files = array_merge($files, glob(__DIR__ . "/" . $inputDir . "/" . $pattern));
|
||||
}
|
||||
|
||||
return array_filter($files, "is_file");
|
||||
}
|
||||
return array_filter($files, "is_file");
|
||||
}
|
||||
|
||||
static public function outputNameFor($input) {
|
||||
$front = _quote(__DIR__ . "/");
|
||||
$out = preg_replace("/^$front/", "", $input);
|
||||
public static function outputNameFor($input) {
|
||||
$front = _quote(__DIR__ . "/");
|
||||
$out = preg_replace("/^$front/", "", $input);
|
||||
|
||||
foreach (self::$testDirs as $inputDir => $outputDir) {
|
||||
$in = _quote($inputDir . "/");
|
||||
$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
|
||||
if ($rewritten != $out) {
|
||||
$out = $rewritten;
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (self::$testDirs as $inputDir => $outputDir) {
|
||||
$in = _quote($inputDir . "/");
|
||||
$rewritten = preg_replace("/$in/", $outputDir . "/", $out);
|
||||
if ($rewritten != $out) {
|
||||
$out = $rewritten;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$out = preg_replace("/.less$/", ".css", $out);
|
||||
$out = preg_replace("/.less$/", ".css", $out);
|
||||
|
||||
return __DIR__ . "/" . $out;
|
||||
}
|
||||
return __DIR__ . "/" . $out;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue