Fix #1927 string * float error in leafo/lessphp

- dev-master 태그로 업데이트
- PHP 8.0 이상 버전에서 오류를 일으키는 {0} 문법 4군데 재수정
This commit is contained in:
Kijin Sung 2022-07-03 00:00:52 +09:00
parent e258cf7525
commit 1f9056fc08
31 changed files with 4558 additions and 4326 deletions

View file

@ -2,14 +2,14 @@
require_once __DIR__ . "/../lessc.inc.php";
class ApiTest extends PHPUnit_Framework_TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");
}
class ApiTest extends PHPUnit\Framework\TestCase {
public function setUp() {
$this->less = new lessc();
$this->less->importDir = array(__DIR__ . "/inputs/test-imports");
}
public function testPreserveComments() {
$input = <<<EOD
public function testPreserveComments() {
$input = <<<EOD
// what is going on?
/** what the heck **/
@ -42,7 +42,7 @@ Here is a block comment
EOD;
$outputWithComments = <<<EOD
$outputWithComments = <<<EOD
/** what the heck **/
/**
@ -69,7 +69,7 @@ div /*yeah*/ {
}
EOD;
$outputWithoutComments = <<<EOD
$outputWithoutComments = <<<EOD
div {
border: 1px solid red;
color: url('http://mage-page.com');
@ -82,71 +82,71 @@ div {
}
EOD;
$this->assertEquals($this->compile($input), trim($outputWithoutComments));
$this->less->setPreserveComments(true);
$this->assertEquals($this->compile($input), trim($outputWithComments));
}
$this->assertEquals($this->compile($input), trim($outputWithoutComments));
$this->less->setPreserveComments(true);
$this->assertEquals($this->compile($input), trim($outputWithComments));
}
public function testOldInterface() {
$this->less = new lessc(__DIR__ . "/inputs/hi.less");
$out = $this->less->parse(array("hello" => "10px"));
$this->assertEquals(trim($out), trim('
public function testOldInterface() {
$this->less = new lessc(__DIR__ . "/inputs/hi.less");
$out = $this->less->parse(array("hello" => "10px"));
$this->assertEquals(trim($out), trim('
div:before {
content: "hi!";
}'));
}
}
public function testInjectVars() {
$out = $this->less->parse(".magic { color: @color; width: @base - 200; }",
array(
'color' => 'red',
'base' => '960px'
));
public function testInjectVars() {
$out = $this->less->parse(".magic { color: @color; width: @base - 200; }",
array(
'color' => 'red',
'base' => '960px'
));
$this->assertEquals(trim($out), trim("
$this->assertEquals(trim($out), trim("
.magic {
color: red;
width: 760px;
}"));
}
}
public function testDisableImport() {
$this->less->importDisabled = true;
$this->assertEquals(
"/* import disabled */",
$this->compile("@import 'file3';"));
}
public function testDisableImport() {
$this->less->importDisabled = true;
$this->assertEquals(
"/* import disabled */",
$this->compile("@import 'file3';"));
}
public function testUserFunction() {
$this->less->registerFunction("add-two", function($list) {
list($a, $b) = $list[2];
return $a[1] + $b[1];
});
public function testUserFunction() {
$this->less->registerFunction("add-two", function($list) {
list($a, $b) = $list[2];
return $a[1] + $b[1];
});
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: 30;");
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: 30;");
return $this->less;
}
return $this->less;
}
/**
* @depends testUserFunction
*/
public function testUnregisterFunction($less) {
$less->unregisterFunction("add-two");
/**
* @depends testUserFunction
*/
public function testUnregisterFunction($less) {
$less->unregisterFunction("add-two");
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: add-two(10,20);");
}
$this->assertEquals(
$this->compile("result: add-two(10, 20);"),
"result: add-two(10,20);");
}
public function testFormatters() {
$src = "
public function testFormatters() {
$src = "
div, pre {
color: blue;
span, .big, hello.world {
@ -155,14 +155,14 @@ div:before {
}
}";
$this->less->setFormatter("compressed");
$this->assertEquals(
$this->compile($src), "div,pre{color:blue;}div span,div .big,div hello.world,pre span,pre .big,pre hello.world{height:20px;color:#fff;}");
$this->less->setFormatter("compressed");
$this->assertEquals(
$this->compile($src), "div,pre{color:blue;}div span,div .big,div hello.world,pre span,pre .big,pre hello.world{height:20px;color:#fff;}");
// TODO: fix the output order of tags
$this->less->setFormatter("lessjs");
$this->assertEquals(
$this->compile($src),
// TODO: fix the output order of tags
$this->less->setFormatter("lessjs");
$this->assertEquals(
$this->compile($src),
"div,
pre {
color: blue;
@ -177,9 +177,9 @@ pre hello.world {
color: #ffffff;
}");
$this->less->setFormatter("classic");
$this->assertEquals(
$this->compile($src),
$this->less->setFormatter("classic");
$this->assertEquals(
$this->compile($src),
trim("div, pre { color:blue; }
div span, div .big, div hello.world, pre span, pre .big, pre hello.world {
height:20px;
@ -187,10 +187,10 @@ div span, div .big, div hello.world, pre span, pre .big, pre hello.world {
}
"));
}
}
public function compile($str) {
return trim($this->less->parse($str));
}
public function compile($str) {
return trim($this->less->parse($str));
}
}