2022-12-01 01:48:42 +00:00
|
|
|
<?php
|
|
|
|
|
2024-07-12 02:01:03 +00:00
|
|
|
namespace Joby\HTML\Html5;
|
2022-12-01 01:48:42 +00:00
|
|
|
|
2024-07-12 02:01:03 +00:00
|
|
|
use Joby\HTML\Containers\DocumentTags\BodyTagInterface;
|
|
|
|
use Joby\HTML\Containers\DocumentTags\DoctypeInterface;
|
|
|
|
use Joby\HTML\Containers\DocumentTags\HeadTagInterface;
|
|
|
|
use Joby\HTML\Containers\DocumentTags\HtmlTagInterface;
|
2022-12-01 01:48:42 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
2024-07-12 01:33:51 +00:00
|
|
|
class GenericHtmlDocumentTest extends TestCase
|
2022-12-01 01:48:42 +00:00
|
|
|
{
|
|
|
|
public function testConstruction(): void
|
|
|
|
{
|
2022-12-16 18:58:23 +00:00
|
|
|
$document = new Html5Document;
|
2022-12-01 01:48:42 +00:00
|
|
|
// all the right classes
|
|
|
|
$this->assertInstanceOf(DoctypeInterface::class, $document->doctype());
|
|
|
|
$this->assertInstanceOf(HtmlTagInterface::class, $document->html());
|
|
|
|
$this->assertInstanceOf(BodyTagInterface::class, $document->body());
|
|
|
|
$this->assertInstanceOf(HeadTagInterface::class, $document->head());
|
|
|
|
// body and head are being passed properly
|
2022-12-13 01:34:42 +00:00
|
|
|
$this->assertEquals($document->body(), $document->html()->body());
|
|
|
|
$this->assertEquals($document->head(), $document->html()->head());
|
2022-12-01 01:48:42 +00:00
|
|
|
// everything has the correct document
|
2022-12-12 20:04:46 +00:00
|
|
|
$this->assertEquals($document, $document->doctype()->parentDocument());
|
|
|
|
$this->assertEquals($document, $document->html()->parentDocument());
|
|
|
|
$this->assertEquals($document, $document->body()->parentDocument());
|
|
|
|
$this->assertEquals($document, $document->head()->parentDocument());
|
2022-12-01 01:48:42 +00:00
|
|
|
// string version of an empty document
|
|
|
|
$this->assertEquals(
|
|
|
|
implode(
|
|
|
|
PHP_EOL,
|
|
|
|
[
|
|
|
|
'<!DOCTYPE html>',
|
|
|
|
'<html>',
|
|
|
|
'<head>',
|
2023-09-08 01:19:39 +00:00
|
|
|
'<title>Untitled</title>',
|
2022-12-01 01:48:42 +00:00
|
|
|
'</head>',
|
|
|
|
'<body></body>',
|
|
|
|
'</html>'
|
|
|
|
]
|
|
|
|
),
|
|
|
|
$document->__toString()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|