-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LiveComponent] Tests class merging with whitespaces
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/LiveComponent/tests/Integration/LiveController/LiveControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent\Tests\Integration\LiveController; | ||
|
||
use Symfony\Component\Panther\PantherTestCase; | ||
|
||
/** | ||
* @author Alexander Hofbauer <[email protected]> | ||
*/ | ||
class LiveControllerTest extends PantherTestCase | ||
{ | ||
public function testWhitespaceClasses(): void | ||
{ | ||
$client = self::createPantherClient(); | ||
$client->request('GET', '/whitespace-classes'); | ||
$client->clickLink('Remove class and render'); | ||
|
||
self::assertSelectorAttributeContains('p[id="content"]', 'class', 'second new'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/LiveComponent/tests/app/src/Twig/Component/WhitespaceClasses.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace App\Twig\Component; | ||
|
||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
use Symfony\UX\LiveComponent\Attribute\LiveAction; | ||
use Symfony\UX\LiveComponent\Attribute\LiveProp; | ||
use Symfony\UX\LiveComponent\DefaultActionTrait; | ||
|
||
/** | ||
* @author Alexander Hofbauer <[email protected]> | ||
*/ | ||
#[AsLiveComponent('whitespace_classes')] | ||
final class WhitespaceClasses | ||
{ | ||
use DefaultActionTrait; | ||
|
||
#[LiveProp] | ||
public string $class = 'third'; | ||
|
||
#[LiveAction] | ||
public function click(): void | ||
{ | ||
$this->class = 'new'; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/LiveComponent/tests/app/templates/components/whitespace_classes.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div{{ attributes }}> | ||
<p | ||
id="content" | ||
class=" | ||
first | ||
second | ||
{{ class }} | ||
" | ||
> | ||
<span>Class: {{ class }}</span> | ||
</p> | ||
|
||
<a | ||
href="#" | ||
data-action="live#action" | ||
data-live-action-param="click" | ||
onclick="document.querySelector('p').classList.remove('first')" | ||
> | ||
Remove class and render | ||
</a> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
src/LiveComponent/tests/app/templates/whitespace_classes.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block body %} | ||
<twig:whitespace_classes /> | ||
{% endblock %} |