Skip to content

Commit f036005

Browse files
authored
[TASK] Add assertInstanceOf tests for CSSListItem (#1237)
These should probably have been added as part of #1212. They confirm that the various types supplanted by `CSSListItem` in the API all implement the new interface. Resolves #1236.
1 parent b74cf2e commit f036005

9 files changed

+221
-2
lines changed

tests/Unit/CSSList/AtRuleBlockListTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Sabberworm\CSS\CSSList\AtRuleBlockList;
1010
use Sabberworm\CSS\CSSList\CSSBlockList;
1111
use Sabberworm\CSS\CSSList\CSSList;
12+
use Sabberworm\CSS\CSSList\CSSListItem;
1213
use Sabberworm\CSS\Property\AtRule;
1314
use Sabberworm\CSS\Renderable;
1415

@@ -49,6 +50,16 @@ public function implementsCommentable(): void
4950
self::assertInstanceOf(Commentable::class, $subject);
5051
}
5152

53+
/**
54+
* @test
55+
*/
56+
public function implementsCSSListItem(): void
57+
{
58+
$subject = new AtRuleBlockList('supports');
59+
60+
self::assertInstanceOf(CSSListItem::class, $subject);
61+
}
62+
5263
/**
5364
* @test
5465
*/

tests/Unit/CSSList/CSSListTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPUnit\Framework\TestCase;
88
use Sabberworm\CSS\Comment\Commentable;
99
use Sabberworm\CSS\CSSElement;
10+
use Sabberworm\CSS\CSSList\CSSListItem;
1011
use Sabberworm\CSS\Renderable;
1112
use Sabberworm\CSS\RuleSet\DeclarationBlock;
1213
use Sabberworm\CSS\Tests\Unit\CSSList\Fixtures\ConcreteCSSList;
@@ -46,6 +47,16 @@ public function implementsCommentable(): void
4647
self::assertInstanceOf(Commentable::class, $subject);
4748
}
4849

50+
/**
51+
* @test
52+
*/
53+
public function implementsCSSListItem(): void
54+
{
55+
$subject = new ConcreteCSSList();
56+
57+
self::assertInstanceOf(CSSListItem::class, $subject);
58+
}
59+
4960
/**
5061
* @test
5162
*/

tests/Unit/CSSList/KeyFrameTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPUnit\Framework\TestCase;
88
use Sabberworm\CSS\Comment\Commentable;
99
use Sabberworm\CSS\CSSList\CSSList;
10+
use Sabberworm\CSS\CSSList\CSSListItem;
1011
use Sabberworm\CSS\CSSList\KeyFrame;
1112
use Sabberworm\CSS\Property\AtRule;
1213
use Sabberworm\CSS\Renderable;
@@ -47,6 +48,16 @@ public function implementsCommentable(): void
4748
self::assertInstanceOf(Commentable::class, $subject);
4849
}
4950

51+
/**
52+
* @test
53+
*/
54+
public function implementsCSSListItem(): void
55+
{
56+
$subject = new KeyFrame();
57+
58+
self::assertInstanceOf(CSSListItem::class, $subject);
59+
}
60+
5061
/**
5162
* @test
5263
*/
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\Property;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\CSSList\CSSListItem;
9+
use Sabberworm\CSS\Property\CSSNamespace;
10+
use Sabberworm\CSS\Value\CSSString;
11+
12+
/**
13+
* @covers \Sabberworm\CSS\Property\CSSNamespace
14+
*/
15+
final class CSSNamespaceTest extends TestCase
16+
{
17+
/**
18+
* @var CSSNamespace
19+
*/
20+
private $subject;
21+
22+
protected function setUp(): void
23+
{
24+
$this->subject = new CSSNamespace(new CSSString('http://www.w3.org/2000/svg'));
25+
}
26+
27+
/**
28+
* @test
29+
*/
30+
public function implementsCSSListItem(): void
31+
{
32+
self::assertInstanceOf(CSSListItem::class, $this->subject);
33+
}
34+
}

tests/Unit/Property/CharsetTest.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\Property;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\CSSList\CSSListItem;
9+
use Sabberworm\CSS\Property\Charset;
10+
use Sabberworm\CSS\Value\CSSString;
11+
12+
/**
13+
* @covers \Sabberworm\CSS\Property\Charset
14+
*/
15+
final class CharsetTest extends TestCase
16+
{
17+
/**
18+
* @var Charset
19+
*/
20+
private $subject;
21+
22+
protected function setUp(): void
23+
{
24+
$this->subject = new Charset(new CSSString('UTF-8'));
25+
}
26+
27+
/**
28+
* @test
29+
*/
30+
public function implementsCSSListItem(): void
31+
{
32+
self::assertInstanceOf(CSSListItem::class, $this->subject);
33+
}
34+
}

tests/Unit/Property/ImportTest.php

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\Property;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\CSSList\CSSListItem;
9+
use Sabberworm\CSS\Property\Import;
10+
use Sabberworm\CSS\Value\CSSString;
11+
use Sabberworm\CSS\Value\URL;
12+
13+
/**
14+
* @covers \Sabberworm\CSS\Property\Import
15+
*/
16+
final class ImportTest extends TestCase
17+
{
18+
/**
19+
* @var Import
20+
*/
21+
private $subject;
22+
23+
protected function setUp(): void
24+
{
25+
$this->subject = new Import(new URL(new CSSString('https://example.org/')), null);
26+
}
27+
28+
/**
29+
* @test
30+
*/
31+
public function implementsCSSListItem(): void
32+
{
33+
self::assertInstanceOf(CSSListItem::class, $this->subject);
34+
}
35+
}

tests/Unit/RuleSet/AtRuleSetTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\RuleSet;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\CSSList\CSSListItem;
9+
use Sabberworm\CSS\RuleSet\AtRuleSet;
10+
11+
/**
12+
* @covers \Sabberworm\CSS\RuleSet\AtRuleSet
13+
*/
14+
final class AtRuleSetTest extends TestCase
15+
{
16+
/**
17+
* @var AtRuleSet
18+
*/
19+
private $subject;
20+
21+
protected function setUp(): void
22+
{
23+
$this->subject = new AtRuleSet('supports');
24+
}
25+
26+
/**
27+
* @test
28+
*/
29+
public function implementsCSSListItem(): void
30+
{
31+
self::assertInstanceOf(CSSListItem::class, $this->subject);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Sabberworm\CSS\Tests\Unit\RuleSet;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use Sabberworm\CSS\CSSList\CSSListItem;
9+
use Sabberworm\CSS\RuleSet\DeclarationBlock;
10+
11+
/**
12+
* @covers \Sabberworm\CSS\RuleSet\DeclarationBlock
13+
*/
14+
final class DeclarationBlockTest extends TestCase
15+
{
16+
/**
17+
* @var DeclarationBlock
18+
*/
19+
private $subject;
20+
21+
protected function setUp(): void
22+
{
23+
$this->subject = new DeclarationBlock();
24+
}
25+
26+
/**
27+
* @test
28+
*/
29+
public function implementsCSSListItem(): void
30+
{
31+
self::assertInstanceOf(CSSListItem::class, $this->subject);
32+
}
33+
}

tests/Unit/RuleSet/RuleSetTest.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@
66

77
use PHPUnit\Framework\TestCase;
88
use Sabberworm\CSS\CSSElement;
9+
use Sabberworm\CSS\CSSList\CSSListItem;
910
use Sabberworm\CSS\Tests\Unit\RuleSet\Fixtures\ConcreteRuleSet;
1011

1112
/**
1213
* @covers \Sabberworm\CSS\RuleSet\RuleSet
1314
*/
1415
final class RuleSetTest extends TestCase
1516
{
17+
/**
18+
* @var ConcreteRuleSet
19+
*/
20+
private $subject;
21+
22+
protected function setUp(): void
23+
{
24+
$this->subject = new ConcreteRuleSet();
25+
}
26+
1627
/**
1728
* @test
1829
*/
1930
public function implementsCSSElement(): void
2031
{
21-
$subject = new ConcreteRuleSet();
32+
self::assertInstanceOf(CSSElement::class, $this->subject);
33+
}
2234

23-
self::assertInstanceOf(CSSElement::class, $subject);
35+
/**
36+
* @test
37+
*/
38+
public function implementsCSSListItem(): void
39+
{
40+
self::assertInstanceOf(CSSListItem::class, $this->subject);
2441
}
2542
}

0 commit comments

Comments
 (0)