3. renders self close class components that extends another class component

580-view-class-steroids
fadrian06 1 day ago
parent 50c23de325
commit bc86e7a298

@ -314,7 +314,12 @@ class ViewTest extends TestCase
<script>console.log('my-class-component-with-scripts')</script> <script>console.log('my-class-component-with-scripts')</script>
html, html,
], ],
[
'page-with-class-component-that-extends-another-class-component',
<<<'html'
another-class-component extended by my-class-component-that-extends-another-class-component
html,
],
]; ];
} }

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace tests\views\components;
use flight\template\Component;
use Override;
if (!class_exists('AnotherClassComponent')) {
class AnotherClassComponent extends Component
{
#[Override]
public function html(): string
{
return 'another-class-component';
}
}
}

@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use tests\views\components\AnotherClassComponent;
require_once __DIR__ . '/another-class-component.php';
return new class extends AnotherClassComponent
{
#[Override]
public function html(): string
{
return parent::html() . ' extended by my-class-component-that-extends-another-class-component';
}
};

@ -9,9 +9,7 @@ return new class extends Component
#[Override] #[Override]
public function html(): string public function html(): string
{ {
return <<<'html' return 'my-class-component-with-scripts';
my-class-component-with-scripts
html;
} }
#[Override] #[Override]

@ -9,8 +9,6 @@ return new class extends Component
#[Override] #[Override]
public function html(): string public function html(): string
{ {
return <<<'html' return 'my-class-component';
my-class-component
html;
} }
}; };

@ -2,6 +2,4 @@
declare(strict_types=1); declare(strict_types=1);
return fn (): string => <<<'html' return fn (): string => 'my-functional-component';
my-functional-component
html;

@ -0,0 +1 @@
<f-my-class-component-that-extends-another-class-component />
Loading…
Cancel
Save