Skip to content

Commit e860529

Browse files
committed
[TASK] Use Property\Declaration in DeclarationBlockTest
This replaces `Rule\Rule`, following #1508. Also use `getPropertyName()` rather than `getRule()` which was deprecated in This covers both the 'functional' and 'unit' flavours of the `TestCase`, and the trait that does most of the heavy lifting for the 'unit' flavour.
1 parent 27da0c8 commit e860529

3 files changed

Lines changed: 278 additions & 278 deletions

File tree

tests/Functional/RuleSet/DeclarationBlockTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use PHPUnit\Framework\TestCase;
88
use Sabberworm\CSS\OutputFormat;
99
use Sabberworm\CSS\Parsing\ParserState;
10+
use Sabberworm\CSS\Property\Declaration;
1011
use Sabberworm\CSS\Property\Selector;
11-
use Sabberworm\CSS\Rule\Rule;
1212
use Sabberworm\CSS\RuleSet\DeclarationBlock;
1313
use Sabberworm\CSS\Settings;
1414

@@ -46,22 +46,22 @@ public function parseReturnsNullForInvalidDeclarationBlock(string $invalidDeclar
4646
/**
4747
* @test
4848
*/
49-
public function rendersRulesInOrderProvided(): void
49+
public function rendersDeclarationsInOrderProvided(): void
5050
{
5151
$declarationBlock = new DeclarationBlock();
5252
$declarationBlock->setSelectors([new Selector('.test')]);
5353

54-
$rule1 = new Rule('background-color');
55-
$rule1->setValue('transparent');
56-
$declarationBlock->addRule($rule1);
54+
$declaration1 = new Declaration('background-color');
55+
$declaration1->setValue('transparent');
56+
$declarationBlock->addRule($declaration1);
5757

58-
$rule2 = new Rule('background');
59-
$rule2->setValue('#222');
60-
$declarationBlock->addRule($rule2);
58+
$declaration2 = new Declaration('background');
59+
$declaration2->setValue('#222');
60+
$declarationBlock->addRule($declaration2);
6161

62-
$rule3 = new Rule('background-color');
63-
$rule3->setValue('#fff');
64-
$declarationBlock->addRule($rule3);
62+
$declaration3 = new Declaration('background-color');
63+
$declaration3->setValue('#fff');
64+
$declarationBlock->addRule($declaration3);
6565

6666
$expectedRendering = 'background-color: transparent;background: #222;background-color: #fff';
6767
self::assertStringContainsString($expectedRendering, $declarationBlock->render(new OutputFormat()));

tests/Unit/RuleSet/DeclarationBlockTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use Sabberworm\CSS\Parsing\ParserState;
1212
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
1313
use Sabberworm\CSS\Position\Positionable;
14+
use Sabberworm\CSS\Property\Declaration;
1415
use Sabberworm\CSS\Property\Selector;
15-
use Sabberworm\CSS\Rule\Rule;
1616
use Sabberworm\CSS\RuleSet\DeclarationBlock;
1717
use Sabberworm\CSS\RuleSet\RuleSet;
1818
use Sabberworm\CSS\Settings;
@@ -391,7 +391,7 @@ public function getRuleSetOnVirginReturnsARuleSet(): void
391391
*/
392392
public function getRuleSetAfterRulesSetReturnsARuleSet(): void
393393
{
394-
$this->subject->setRules([new Rule('color')]);
394+
$this->subject->setRules([new Declaration('color')]);
395395

396396
$result = $this->subject->getRuleSet();
397397

@@ -401,7 +401,7 @@ public function getRuleSetAfterRulesSetReturnsARuleSet(): void
401401
/**
402402
* @test
403403
*/
404-
public function getRuleSetOnVirginReturnsObjectWithoutRules(): void
404+
public function getRuleSetOnVirginReturnsObjectWithoutDeclarations(): void
405405
{
406406
$result = $this->subject->getRuleSet();
407407

@@ -415,14 +415,14 @@ public function getRuleSetOnVirginReturnsObjectWithoutRules(): void
415415
*
416416
* @dataProvider providePropertyNames
417417
*/
418-
public function getRuleSetReturnsObjectWithRulesSet(array $propertyNamesToSet): void
418+
public function getRuleSetReturnsObjectWithDeclarationsSet(array $propertyNamesToSet): void
419419
{
420-
$rules = self::createRulesFromPropertyNames($propertyNamesToSet);
421-
$this->subject->setRules($rules);
420+
$declarations = self::createDeclarationsFromPropertyNames($propertyNamesToSet);
421+
$this->subject->setRules($declarations);
422422

423423
$result = $this->subject->getRuleSet();
424424

425-
self::assertSame($rules, $result->getRules());
425+
self::assertSame($declarations, $result->getRules());
426426
}
427427

428428
/**

0 commit comments

Comments
 (0)