diff --git a/tests/Lib/StyleWithTestableRenderCss.php b/tests/Lib/StyleWithTestableRenderCss.php new file mode 100644 index 00000000..3eea210b --- /dev/null +++ b/tests/Lib/StyleWithTestableRenderCss.php @@ -0,0 +1,10 @@ +setNonce('12345rtzujiklö'); + + $this->assertSame( + '', + $style->render() + ); + } + + public function testModuleScopeIsCorrectlyRendered() + { + $style = new StyleWithTestableRenderCss(); + $style->setModule('foo'); + $style->add('#bar', ['width' => 'auto']); + + $this->assertSame( + <<<'EOT' + +EOT + , + $style->render() + ); + } + + public function testAddForAutomaticallyGeneratesIds() + { + $div = Html::tag('div'); + + $style = new Style(); + $style->addFor($div, ['width' => 'auto']); + + $this->assertNotNull($div->getAttribute('id')->getValue()); + } + + public function testAddForRespectsExistingIds() + { + $div = Html::tag('div', ['id' => 'foo']); + + $style = new StyleWithTestableRenderCss(); + $style->addFor($div, ['width' => 'auto']); + + $this->assertSame( + <<<'EOT' + +EOT + , + $style->render() + ); + } + + /** + * @depends testNonceIsCorrectlyRendered + * @depends testModuleScopeIsCorrectlyRendered + * @depends testAddForRespectsExistingIds + */ + public function testCanBeCastedToString() + { + $div = Html::tag('div', ['id' => 'foo']); + + $style = new StyleWithTestableRenderCss(); + $style->setNonce('12345rtzujiklö'); + $style->setModule('foo'); + $style->addFor($div, ['width' => 'auto']); + + $this->assertSame( + <<<'EOT' + +EOT + , + (string) $style + ); + } +}