Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Sabberworm\CSS\Comment;

use Sabberworm\CSS\OutputFormat;
use Sabberworm\CSS\Renderable;
use Sabberworm\CSS\Position\Position;
use Sabberworm\CSS\Position\Positionable;
use Sabberworm\CSS\Renderable;

class Comment implements Positionable, Renderable
{
Expand Down
12 changes: 6 additions & 6 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,29 +221,29 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
}

/**
* @see RuleSet::getRules()
*
* @return array<int<0, max>, Rule>
*
* @see RuleSet::getRules()
*/
public function getRules(?string $searchPattern = null): array
{
return $this->ruleSet->getRules($searchPattern);
}

/**
* @see RuleSet::setRules()
*
* @param array<Rule> $rules
*
* @see RuleSet::setRules()
*/
public function setRules(array $rules): void
{
$this->ruleSet->setRules($rules);
}

/**
* @see RuleSet::getRulesAssoc()
*
* @return array<string, Rule>
*
* @see RuleSet::getRulesAssoc()
*/
public function getRulesAssoc(?string $searchPattern = null): array
{
Expand Down
14 changes: 10 additions & 4 deletions tests/Comment/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ final class CommentTest extends TestCase
public function keepCommentsInOutput(): void
{
$cssDocument = TestsParserTest::parsedStructureForFile('comments');
self::assertSame('/** Number 11 **/
self::assertSame(
'/** Number 11 **/
Comment on lines +22 to +23
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't read this.


/**
* Comments
Expand All @@ -43,7 +44,9 @@ public function keepCommentsInOutput(): void
position: absolute;
}
}
', $cssDocument->render(OutputFormat::createPretty()));
',
$cssDocument->render(OutputFormat::createPretty())
);
self::assertSame(
'/** Number 11 **//**' . "\n"
. ' * Comments' . "\n"
Expand All @@ -61,7 +64,8 @@ public function keepCommentsInOutput(): void
public function stripCommentsFromOutput(): void
{
$css = TestsParserTest::parsedStructureForFile('comments');
self::assertSame('
self::assertSame(
'
@import url("some/url.css") screen;

.foo, #bar {
Expand All @@ -73,7 +77,9 @@ public function stripCommentsFromOutput(): void
position: absolute;
}
}
', $css->render(OutputFormat::createPretty()->setRenderComments(false)));
',
$css->render(OutputFormat::createPretty()->setRenderComments(false))
);
self::assertSame(
'@import url("some/url.css") screen;'
. '.foo,#bar{background-color:#000}'
Expand Down
52 changes: 32 additions & 20 deletions tests/OutputFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
final class OutputFormatTest extends TestCase
{
private const TEST_CSS = "\n"
. ".main, .test {\n"
. "\tfont: italic normal bold 16px/1.2 \"Helvetica\", Verdana, sans-serif;\n"
. "\tbackground: white;\n"
. "}\n"
. "\n"
. "@media screen {\n"
. "\t.main {\n"
. "\t\tbackground-size: 100% 100%;\n"
. "\t\tfont-size: 1.3em;\n"
. "\t\tbackground-color: #fff;\n"
. "\t}\n"
. "}\n";
. ".main, .test {\n"
. "\tfont: italic normal bold 16px/1.2 \"Helvetica\", Verdana, sans-serif;\n"
. "\tbackground: white;\n"
. "}\n"
. "\n"
. "@media screen {\n"
. "\t.main {\n"
. "\t\tbackground-size: 100% 100%;\n"
. "\t\tfont-size: 1.3em;\n"
. "\t\tbackground-color: #fff;\n"
. "\t}\n"
. "}\n";

/**
* @var Parser
Expand Down Expand Up @@ -181,15 +181,18 @@ public function spaceRules(): void
->setSpaceBetweenRules("\n")
->setSpaceAfterRules("\n");

self::assertSame('.main, .test {
self::assertSame(
'.main, .test {
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
background: white;
}
@media screen {.main {
background-size: 100% 100%;
font-size: 1.3em;
background-color: #fff;
}}', $this->document->render($outputFormat));
}}',
$this->document->render($outputFormat)
);
}

/**
Expand All @@ -202,12 +205,15 @@ public function spaceBlocks(): void
->setSpaceBetweenBlocks("\n")
->setSpaceAfterBlocks("\n");

self::assertSame('
self::assertSame(
'
.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}
@media screen {
.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}
}
', $this->document->render($outputFormat));
',
$this->document->render($outputFormat)
);
}

/**
Expand All @@ -223,7 +229,8 @@ public function spaceBoth(): void
->setSpaceBetweenBlocks("\n")
->setSpaceAfterBlocks("\n");

self::assertSame('
self::assertSame(
'
.main, .test {
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
background: white;
Expand All @@ -235,7 +242,9 @@ public function spaceBoth(): void
background-color: #fff;
}
}
', $this->document->render($outputFormat));
',
$this->document->render($outputFormat)
);
}

/**
Expand Down Expand Up @@ -267,7 +276,8 @@ public function indentation(): void
->setSpaceAfterBlocks("\n")
->setIndentation('');

self::assertSame('
self::assertSame(
'
.main, .test {
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
background: white;
Expand All @@ -279,7 +289,9 @@ public function indentation(): void
background-color: #fff;
}
}
', $this->document->render($outputFormat));
',
$this->document->render($outputFormat)
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Value/CalcFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function parseSimpleCalc(): void
self::assertSame(20.0, $components[2]->getSize());
self::assertSame('px', $components[2]->getUnit());
}

/**
* @test
*/
Expand Down