Skip to content

Commit 7bc087c

Browse files
committed
Tests: Test fallthrough expressions / dynamic fallthrough expressions
1 parent bfe1f8d commit 7bc087c

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Tempest\View\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Tempest\View\Exceptions\ViewComponentPathWasInvalid;
7+
use Tempest\View\Exceptions\ViewComponentPathWasNotFound;
8+
use Tempest\View\Renderers\TempestViewRenderer;
9+
use Tempest\View\ViewCache;
10+
use Tempest\View\ViewComponent;
11+
use Tempest\View\ViewConfig;
12+
13+
use function Tempest\view;
14+
15+
final class FallthroughAttributesTest extends TestCase
16+
{
17+
public function test_render(): void
18+
{
19+
$viewConfig = new ViewConfig()->addViewComponents(
20+
__DIR__ . '/Fixtures/x-fallthrough-test.view.php',
21+
__DIR__ . '/Fixtures/x-fallthrough-dynamic-test.view.php',
22+
);
23+
24+
$renderer =
25+
TempestViewRenderer::make(
26+
viewConfig: $viewConfig,
27+
);
28+
29+
$html = $renderer->render(
30+
view(__DIR__ . '/Fixtures/fallthrough.view.php'),
31+
);
32+
33+
$this->assertEquals(<<<'HTML'
34+
<div class="in-component component-class"></div>
35+
<div class="in-component component-class"></div>
36+
<div class="component-class" style="display: block;"></div>
37+
<div class="component-class" style="display: block;"></div>
38+
HTML, $html);
39+
}
40+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
$componentClass = 'component-class';
3+
$componentStyle = 'display: block;';
4+
?><x-fallthrough-test class="component-class" />
5+
<x-fallthrough-test :class="$componentClass" />
6+
<x-fallthrough-dynamic-test c="component-class" s="display: block;" />
7+
<x-fallthrough-dynamic-test :c="$componentClass" :s="$componentStyle"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div :class="$attributes->get('c')" :style="$attributes->get('s')"></div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div class="in-component"></div>

0 commit comments

Comments
 (0)