diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c1207fb..5e78f38 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,8 @@ tests/ParsedownTest.php - tests/CommonMarkTest.php + tests/CommonMarkTest.php + ./tests/src diff --git a/psalm.xml b/psalm.xml index d3f2f25..0ad9b82 100644 --- a/psalm.xml +++ b/psalm.xml @@ -13,16 +13,7 @@ - - - - - - - - - @@ -37,5 +28,17 @@ + + + + + + + + + + + + diff --git a/tests/src/Components/Inlines/PlainTextTest.php b/tests/src/Components/Inlines/PlainTextTest.php new file mode 100644 index 0000000..de1bd4b --- /dev/null +++ b/tests/src/Components/Inlines/PlainTextTest.php @@ -0,0 +1,22 @@ +assertSame('foo', $Plaintext->text()); + } +} diff --git a/tests/src/Html/Renderables/ContainerTest.php b/tests/src/Html/Renderables/ContainerTest.php new file mode 100644 index 0000000..d7cdff1 --- /dev/null +++ b/tests/src/Html/Renderables/ContainerTest.php @@ -0,0 +1,31 @@ +contents(); + + $this->assertTrue($Contents[0] instanceof Element); + $this->assertSame($Contents[0]->name(), 'foo'); + $this->assertTrue($Contents[1] instanceof Text); + $this->assertSame($Contents[1]->getHtml(), 'bar'); + } +} diff --git a/tests/src/Html/Renderables/ElementTest.php b/tests/src/Html/Renderables/ElementTest.php new file mode 100644 index 0000000..036a9d9 --- /dev/null +++ b/tests/src/Html/Renderables/ElementTest.php @@ -0,0 +1,67 @@ + 'baz', + 'boo' => 'bim', + ], + [new Text('zoo')] + ); + + $this->assertSame($Element->name(), 'foo'); + $this->assertSame( + $Element->attributes(), + [ + 'bar' => 'baz', + 'boo' => 'bim', + ] + ); + $this->assertTrue($Element->contents()[0] instanceof Text); + $this->assertSame($Element->contents()[0]->getHtml(), 'zoo'); + } + + /** + * @return void + * @throws \PHPUnit\Framework\ExpectationFailedException + * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException + */ + public function testSettingElementProperties() + { + $Element = new Element( + 'foo', + [ + 'bar' => 'baz', + 'boo' => 'bim', + ], + [new Text('zoo')] + ); + + $Element = $Element + ->settingAttributes(['bar' => 'bim']) + ->settingContents(null) + ; + + $this->assertSame($Element->name(), 'foo'); + $this->assertSame($Element->attributes(), ['bar' => 'bim']); + $this->assertSame($Element->contents(), null); + + $Element = $Element->settingName('foo1'); + $this->assertSame($Element->name(), 'foo1'); + } +} diff --git a/tests/src/StateTest.php b/tests/src/StateTest.php new file mode 100644 index 0000000..22d5311 --- /dev/null +++ b/tests/src/StateTest.php @@ -0,0 +1,32 @@ +assertFalse($State->get(SafeMode::class)->isEnabled()); + $this->assertFalse($State->get(StrictMode::class)->isEnabled()); + $this->assertFalse($State->get(Breaks::class)->isEnabled()); + + $UpdatedState = $State->mergingWith(new State([SafeMode::enabled()])); + + $this->assertTrue($UpdatedState->get(SafeMode::class)->isEnabled()); + $this->assertFalse($UpdatedState->get(StrictMode::class)->isEnabled()); + $this->assertFalse($UpdatedState->get(Breaks::class)->isEnabled()); + } +}