Skip to content

Commit 99202fb

Browse files
authored
[BUGFIX] Provide the usual set of delimiters in parseValue tests (#618)
In the test cases added so far, this doesn't seem to affect results, but would be needed for tests that may be added in future to ensure consistencey with how the method is actually used at runtime. Co-authored-by: Jake Hotson <jake.github@qzdesign.co.uk>
1 parent cc53c85 commit 99202fb

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tests/Value/ValueTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
*/
1515
final class ValueTest extends TestCase
1616
{
17+
/**
18+
* the default set of delimiters for parsing most values
19+
*
20+
* @see \Rule\Rule::listDelimiterForRule
21+
*
22+
* @var array<int, string>
23+
*/
24+
private const DEFAULT_DELIMITERS = [',', ' ', '/'];
25+
1726
/**
1827
* @return array<string, array{0: string}>
1928
*/
@@ -39,7 +48,10 @@ function (string $unit): array {
3948
*/
4049
public function parsesArithmeticInFunctions(string $operator): void
4150
{
42-
$subject = Value::parseValue(new ParserState('max(300px, 50vh ' . $operator . ' 10px);', Settings::create()));
51+
$subject = Value::parseValue(
52+
new ParserState('max(300px, 50vh ' . $operator . ' 10px);', Settings::create()),
53+
self::DEFAULT_DELIMITERS
54+
);
4355

4456
self::assertSame('max(300px,50vh ' . $operator . ' 10px)', (string) $subject);
4557
}
@@ -74,7 +86,10 @@ public function parsesArithmeticWithMultipleOperatorsInFunctions(
7486
): void {
7587
static $expression = '300px + 10% + 10vw';
7688

77-
$subject = Value::parseValue(new ParserState(\sprintf($parserTemplate, $expression), Settings::create()));
89+
$subject = Value::parseValue(
90+
new ParserState(\sprintf($parserTemplate, $expression), Settings::create()),
91+
self::DEFAULT_DELIMITERS
92+
);
7893

7994
self::assertSame(\sprintf($expectedResultTemplate, $expression), (string) $subject);
8095
}
@@ -99,10 +114,10 @@ public static function provideMalformedLengthOperands(): array
99114
*/
100115
public function parsesArithmeticWithMalformedOperandsInFunctions(string $leftOperand, string $rightOperand): void
101116
{
102-
$subject = Value::parseValue(new ParserState(
103-
'max(300px, ' . $leftOperand . ' + ' . $rightOperand . ');',
104-
Settings::create()
105-
));
117+
$subject = Value::parseValue(
118+
new ParserState('max(300px, ' . $leftOperand . ' + ' . $rightOperand . ');', Settings::create()),
119+
self::DEFAULT_DELIMITERS
120+
);
106121

107122
self::assertSame('max(300px,' . $leftOperand . ' + ' . $rightOperand . ')', (string) $subject);
108123
}

0 commit comments

Comments
 (0)