getContent());
self::assertSame("
le titre
\n<helloworld>print!static-content!generated-content!", $content);
}
function testPrint() {
$component = new MyComponent();
ob_start(null, 0, PHP_OUTPUT_HANDLER_STDFLAGS ^ PHP_OUTPUT_HANDLER_FLUSHABLE);
$component->print();
$content = ob_get_clean();
self::assertSame("le titre
\n<helloworld>print!static-content!generated-content!", $content);
}
}
class ZePrint implements IPrintable {
function print(): void {
echo "print!";
}
}
class ZeStaticContent implements IContent {
function getContent(): array {
return ["static-content!"];
}
}
class ZeGeneratedContent implements IContent {
function getContent(): iterable {
yield "generated-content!";
}
}
class MyComponent extends SimplePrintable {
function print(): void {
vo::h1(null);
vo::h1("le titre");
vo::write("");
vo::write([""]);
vo::write(new ZePrint());
vo::write(new ZeStaticContent());
vo::write(new ZeGeneratedContent());
}
}