Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions packages/view/tests/FallthroughAttributesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Tempest\View\Tests;

use PHPUnit\Framework\TestCase;
use Tempest\View\Exceptions\ViewComponentPathWasInvalid;
use Tempest\View\Exceptions\ViewComponentPathWasNotFound;
use Tempest\View\Renderers\TempestViewRenderer;
use Tempest\View\ViewCache;
use Tempest\View\ViewComponent;
use Tempest\View\ViewConfig;

use function Tempest\view;

final class FallthroughAttributesTest extends TestCase
{
public function test_render(): void
{
$viewConfig = new ViewConfig()->addViewComponents(
__DIR__ . '/Fixtures/x-fallthrough-test.view.php',
__DIR__ . '/Fixtures/x-fallthrough-dynamic-test.view.php',
);

$renderer =
TempestViewRenderer::make(
viewConfig: $viewConfig,
);

$html = $renderer->render(
view(__DIR__ . '/Fixtures/fallthrough.view.php'),
);

$this->assertEquals(<<<'HTML'

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - postgres - prefer-stable - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - sqlite - prefer-stable - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - sqlite - prefer-lowest - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - postgres - prefer-lowest - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - mysql - prefer-lowest - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: PHP 8.4 - mysql - prefer-stable - ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: view - PHP 8.4 - prefer-lowest

Failed asserting that two strings are equal.

Check failure on line 33 in packages/view/tests/FallthroughAttributesTest.php

View workflow job for this annotation

GitHub Actions / Run tests: view - PHP 8.4 - prefer-stable

Failed asserting that two strings are equal.
<div class="in-component component-class"></div>
<div class="in-component component-class"></div>
<div class="component-class" style="display: block;"></div>
<div class="component-class" style="display: block;"></div>
HTML, $html);
}
}
7 changes: 7 additions & 0 deletions packages/view/tests/Fixtures/fallthrough.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$componentClass = 'component-class';
$componentStyle = 'display: block;';
?><x-fallthrough-test class="component-class" />
<x-fallthrough-test :class="$componentClass" />
<x-fallthrough-dynamic-test c="component-class" s="display: block;" />
<x-fallthrough-dynamic-test :c="$componentClass" :s="$componentStyle"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div :class="$attributes->get('c')" :style="$attributes->get('s')"></div>
1 change: 1 addition & 0 deletions packages/view/tests/Fixtures/x-fallthrough-test.view.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="in-component"></div>
Loading