From d2eac7711efa6fbff7b8b630e028f85d73d1e032 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 1 Jan 2026 10:20:28 +0100 Subject: [PATCH] [TASK] Add more stub tests for `getArrayRepresentation()` Part of #1440 --- tests/Unit/CSSList/AtRuleBlockListTest.php | 12 +++++++++ tests/Unit/CSSList/CSSBlockListTest.php | 12 +++++++++ tests/Unit/CSSList/DocumentTest.php | 12 +++++++++ tests/Unit/CSSList/KeyFrameTest.php | 12 +++++++++ tests/Unit/Property/KeyframeSelectorTest.php | 27 +++++++++++++++++++ tests/Unit/RuleSet/AtRuleSetTest.php | 10 +++++++ tests/Unit/Value/CSSFunctionTest.php | 28 ++++++++++++++++++++ tests/Unit/Value/CSSStringTest.php | 12 +++++++++ tests/Unit/Value/CalcFunctionTest.php | 12 +++++++++ tests/Unit/Value/CalcRuleValueListTest.php | 12 +++++++++ tests/Unit/Value/ColorTest.php | 12 +++++++++ tests/Unit/Value/LineNameTest.php | 28 ++++++++++++++++++++ tests/Unit/Value/RuleValueListTest.php | 28 ++++++++++++++++++++ tests/Unit/Value/SizeTest.php | 12 +++++++++ tests/Unit/Value/URLTest.php | 12 +++++++++ 15 files changed, 241 insertions(+) create mode 100644 tests/Unit/Property/KeyframeSelectorTest.php create mode 100644 tests/Unit/Value/CSSFunctionTest.php create mode 100644 tests/Unit/Value/LineNameTest.php create mode 100644 tests/Unit/Value/RuleValueListTest.php diff --git a/tests/Unit/CSSList/AtRuleBlockListTest.php b/tests/Unit/CSSList/AtRuleBlockListTest.php index 3b61e437e..416c8819f 100644 --- a/tests/Unit/CSSList/AtRuleBlockListTest.php +++ b/tests/Unit/CSSList/AtRuleBlockListTest.php @@ -144,4 +144,16 @@ public function isRootListAlwaysReturnsFalse(): void self::assertFalse($subject->isRootList()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new AtRuleBlockList('media'); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/CSSList/CSSBlockListTest.php b/tests/Unit/CSSList/CSSBlockListTest.php index ce7e54477..50b6420ef 100644 --- a/tests/Unit/CSSList/CSSBlockListTest.php +++ b/tests/Unit/CSSList/CSSBlockListTest.php @@ -471,4 +471,16 @@ public function getAllValuesWithSearchInFunctionArgumentsReturnsValuesInFunction self::assertSame([$value1, $value2], $result); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new ConcreteCSSBlockList(); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/CSSList/DocumentTest.php b/tests/Unit/CSSList/DocumentTest.php index 77e8aa81c..c1d0f614a 100644 --- a/tests/Unit/CSSList/DocumentTest.php +++ b/tests/Unit/CSSList/DocumentTest.php @@ -63,4 +63,16 @@ public function isRootListAlwaysReturnsTrue(): void self::assertTrue($subject->isRootList()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new Document(); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/CSSList/KeyFrameTest.php b/tests/Unit/CSSList/KeyFrameTest.php index e191a440e..b77f295db 100644 --- a/tests/Unit/CSSList/KeyFrameTest.php +++ b/tests/Unit/CSSList/KeyFrameTest.php @@ -108,4 +108,16 @@ public function getVendorKeyFrameByDefaultReturnsKeyframes(): void self::assertSame('keyframes', $subject->getVendorKeyFrame()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new KeyFrame(); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Property/KeyframeSelectorTest.php b/tests/Unit/Property/KeyframeSelectorTest.php new file mode 100644 index 000000000..2f7cebacb --- /dev/null +++ b/tests/Unit/Property/KeyframeSelectorTest.php @@ -0,0 +1,27 @@ +expectException(\BadMethodCallException::class); + + $subject = new KeyframeSelector('a'); + + $subject->getArrayRepresentation(); + } +} diff --git a/tests/Unit/RuleSet/AtRuleSetTest.php b/tests/Unit/RuleSet/AtRuleSetTest.php index 0e3e0c974..74c60a04a 100644 --- a/tests/Unit/RuleSet/AtRuleSetTest.php +++ b/tests/Unit/RuleSet/AtRuleSetTest.php @@ -30,4 +30,14 @@ public function implementsCSSListItem(): void { self::assertInstanceOf(CSSListItem::class, $this->subject); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $this->subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/CSSFunctionTest.php b/tests/Unit/Value/CSSFunctionTest.php new file mode 100644 index 000000000..8600c569e --- /dev/null +++ b/tests/Unit/Value/CSSFunctionTest.php @@ -0,0 +1,28 @@ +expectException(\BadMethodCallException::class); + + $subject = new CSSFunction('filter', []); + + $subject->getArrayRepresentation(); + } +} diff --git a/tests/Unit/Value/CSSStringTest.php b/tests/Unit/Value/CSSStringTest.php index c54ecdd75..d967d2841 100644 --- a/tests/Unit/Value/CSSStringTest.php +++ b/tests/Unit/Value/CSSStringTest.php @@ -80,4 +80,16 @@ public function getLineNumberReturnsLineNumberProvidedToConstructor(): void self::assertSame($lineNumber, $subject->getLineNumber()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new CSSString(''); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/CalcFunctionTest.php b/tests/Unit/Value/CalcFunctionTest.php index 65f23e131..330c43b72 100644 --- a/tests/Unit/Value/CalcFunctionTest.php +++ b/tests/Unit/Value/CalcFunctionTest.php @@ -198,4 +198,16 @@ private function parse(string $css): CalcFunction self::assertInstanceOf(CalcFunction::class, $function); return $function; } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new CalcFunction('calc', []); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/CalcRuleValueListTest.php b/tests/Unit/Value/CalcRuleValueListTest.php index 7314e3c51..a02c05f7d 100644 --- a/tests/Unit/Value/CalcRuleValueListTest.php +++ b/tests/Unit/Value/CalcRuleValueListTest.php @@ -56,4 +56,16 @@ public function separatorAlwaysIsComma(): void self::assertSame(',', $subject->getListSeparator()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new CalcRuleValueList(); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/ColorTest.php b/tests/Unit/Value/ColorTest.php index aaa257553..0311f9e5e 100644 --- a/tests/Unit/Value/ColorTest.php +++ b/tests/Unit/Value/ColorTest.php @@ -471,4 +471,16 @@ public function throwsExceptionWithInvalidColor(string $color): void Color::parse(new ParserState($color, Settings::create())); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new Color([]); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/LineNameTest.php b/tests/Unit/Value/LineNameTest.php new file mode 100644 index 000000000..e48670f8a --- /dev/null +++ b/tests/Unit/Value/LineNameTest.php @@ -0,0 +1,28 @@ +expectException(\BadMethodCallException::class); + + $subject = new LineName(); + + $subject->getArrayRepresentation(); + } +} diff --git a/tests/Unit/Value/RuleValueListTest.php b/tests/Unit/Value/RuleValueListTest.php new file mode 100644 index 000000000..e82d255ab --- /dev/null +++ b/tests/Unit/Value/RuleValueListTest.php @@ -0,0 +1,28 @@ +expectException(\BadMethodCallException::class); + + $subject = new RuleValueList(); + + $subject->getArrayRepresentation(); + } +} diff --git a/tests/Unit/Value/SizeTest.php b/tests/Unit/Value/SizeTest.php index c80f788cd..fe86cf761 100644 --- a/tests/Unit/Value/SizeTest.php +++ b/tests/Unit/Value/SizeTest.php @@ -98,4 +98,16 @@ public function parsesUnit(string $unit): void self::assertSame($unit, $parsedSize->getUnit()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new Size(1); + + $subject->getArrayRepresentation(); + } } diff --git a/tests/Unit/Value/URLTest.php b/tests/Unit/Value/URLTest.php index 66654e647..8b4c08809 100644 --- a/tests/Unit/Value/URLTest.php +++ b/tests/Unit/Value/URLTest.php @@ -80,4 +80,16 @@ public function getLineNumberReturnsLineNumberProvidedToConstructor(): void self::assertSame($lineNumber, $subject->getLineNumber()); } + + /** + * @test + */ + public function getArrayRepresentationThrowsException(): void + { + $this->expectException(\BadMethodCallException::class); + + $subject = new URL(new CSSString('http://example.com')); + + $subject->getArrayRepresentation(); + } }