head = new Head(); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The head has the expected default values after initialization')] public function testDefault() : void { self::assertInstanceOf('\phpOMS\Model\Html\Meta', $this->head->meta); self::assertEquals('', $this->head->title); self::assertEquals('en', $this->head->language); self::assertEquals([], $this->head->getStyleAll()); self::assertEquals([], $this->head->getScriptAll()); self::assertEquals('', $this->head->renderStyle()); self::assertEquals('', $this->head->renderScript()); self::assertEquals('', $this->head->renderAssets()); self::assertEquals('', $this->head->renderAssetsLate()); self::assertEquals('', $this->head->render()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The title can be set and returned')] public function testTitleInputOutput() : void { $this->head->title = 'my title'; self::assertEquals('my title', $this->head->title); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The style can be set and returned')] public function testStyleInputOutput() : void { $this->head->setStyle('base', '#test .class { color: #000; }'); self::assertEquals(['base' => '#test .class { color: #000; }'], $this->head->getStyleAll()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The script can be set and returned')] public function testScriptInputOutput() : void { $this->head->setScript('key', 'console.log("msg");'); self::assertEquals(['key' => 'console.log("msg");'], $this->head->getScriptAll()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The assets can be set and rendered')] public function testAssetRender() : void { $this->head->addAsset(AssetType::CSS, '/path/styles.css'); $this->head->addAsset(AssetType::JS, '/path/logic.js'); $this->head->setStyle('base', '#test .class { color: #000; }'); $this->head->setScript('key', 'console.log("msg");'); self::assertEquals( '' . '' . '' . '' . '', $this->head->render() ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The assets can be set and rendered at the end of the document')] public function testAssetLateRender() : void { $this->head->addAsset(AssetType::JSLATE, '/path/late.js'); self::assertEquals('', $this->head->renderAssetsLate()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The assets can be set and rendered with attributes')] public function testAssetRenderWithAttribute() : void { $this->head->addAsset(AssetType::JS, '/path/late.js', ['testkey' => 'testvalue']); self::assertEquals('', $this->head->renderAssets()); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('The assets can be set and rendered at the end of the document with attributes')] public function testAssetLateRenderWithAttribute() : void { $this->head->addAsset(AssetType::JSLATE, '/path/late.js', ['testkey' => 'testvalue']); self::assertEquals('', $this->head->renderAssetsLate()); } }