-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Functional tests for Symfony & Twig integration
- Loading branch information
Showing
6 changed files
with
113 additions
and
12 deletions.
There are no files selected for viewing
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
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
31 changes: 31 additions & 0 deletions
31
tests/Extension/Symfony/Fixtures/Controller/FiniteController.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,31 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Finite\Tests\Extension\Symfony\Fixtures\Controller; | ||
|
||
use Finite\Tests\Extension\Symfony\Fixtures\Model\Document; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Twig\Environment; | ||
|
||
final class FiniteController | ||
{ | ||
public function __construct( | ||
private readonly Environment $twig, | ||
) | ||
{ | ||
} | ||
|
||
public function __invoke(): Response | ||
{ | ||
$document = new Document; | ||
|
||
return new Response( | ||
$this->twig->render( | ||
'finite.html.twig', | ||
[ | ||
'document' => $document, | ||
] | ||
), | ||
); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
tests/Extension/Symfony/Fixtures/app/templates/finite.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,7 @@ | ||
<div class="can">{{ finite_can(document, 'publish') ? 'yes' : 'no' }}</div> | ||
<div class="cannot">{{ finite_can(document, 'clear') ? 'yes' : 'no' }}</div> | ||
<div class="reachables"> | ||
{%- for transition in finite_reachable_transitions(document)%} | ||
<span>{{ transition.name }}</span> | ||
{%- endfor -%} | ||
</div> |
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,25 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Finite\Tests\Extension\Symfony\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class FiniteTest extends WebTestCase | ||
{ | ||
public function test_finite_controller(): void | ||
{ | ||
$client = $this->createClient(); | ||
$client->request('GET', '/finite'); | ||
|
||
$this->assertResponseIsSuccessful(); | ||
$this->assertSelectorTextContains('.can', 'yes'); | ||
$this->assertSelectorTextContains('.cannot', 'no'); | ||
$this->assertSelectorTextContains('.reachables', 'publish'); | ||
} | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return \AppKernel::class; | ||
} | ||
} |