Skip to content

[TASK] Avoid the deprecated __toString() in tests #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/Unit/Value/ColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Sabberworm\CSS\Tests\Unit\Value;

use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Parsing\ParserState;
use Sabberworm\CSS\Parsing\SourceException;
use Sabberworm\CSS\Settings;
Expand Down Expand Up @@ -346,7 +347,7 @@ public function parsesAndRendersValidColor(string $color, string $expectedRender
{
$subject = Color::parse(new ParserState($color, Settings::create()));

$renderedResult = (string) $subject;
$renderedResult = $subject->render(OutputFormat::create());

self::assertSame($expectedRendering, $renderedResult);
}
Expand Down
17 changes: 14 additions & 3 deletions tests/Unit/Value/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace Sabberworm\CSS\Tests\Unit\Value;

use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Parsing\ParserState;
use Sabberworm\CSS\Settings;
use Sabberworm\CSS\Value\CSSFunction;
use Sabberworm\CSS\Value\Value;

/**
Expand Down Expand Up @@ -48,7 +50,8 @@ public function parsesArithmeticInFunctions(string $operator): void
self::DEFAULT_DELIMITERS
);

self::assertSame('max(300px,50vh ' . $operator . ' 10px)', (string) $subject);
self::assertInstanceOf(CSSFunction::class, $subject);
self::assertSame('max(300px,50vh ' . $operator . ' 10px)', $subject->render(OutputFormat::createCompact()));
}

/**
Expand Down Expand Up @@ -90,7 +93,11 @@ public function parsesArithmeticWithMultipleOperatorsInFunctions(
self::DEFAULT_DELIMITERS
);

self::assertSame(\sprintf($expectedResultTemplate, $expression), (string) $subject);
self::assertInstanceOf(CSSFunction::class, $subject);
self::assertSame(
\sprintf($expectedResultTemplate, $expression),
$subject->render(OutputFormat::createCompact())
);
}

/**
Expand Down Expand Up @@ -118,6 +125,10 @@ public function parsesArithmeticWithMalformedOperandsInFunctions(string $leftOpe
self::DEFAULT_DELIMITERS
);

self::assertSame('max(300px,' . $leftOperand . ' + ' . $rightOperand . ')', (string) $subject);
self::assertInstanceOf(CSSFunction::class, $subject);
self::assertSame(
'max(300px,' . $leftOperand . ' + ' . $rightOperand . ')',
$subject->render(OutputFormat::createCompact())
);
}
}