Skip to content

Commit

Permalink
fix(symfony): Fixed twig extension declaration
Browse files Browse the repository at this point in the history
yohang committed Jan 13, 2025

Verified

This commit was signed with the committer’s verified signature.
yohang Yohan Giarelli
1 parent 57d58fd commit 3238aa5
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -32,7 +32,8 @@
"symfony/http-kernel": ">=5.4,<8",
"symfony/framework-bundle": ">=5.4,<8",
"symfony/event-dispatcher": ">=5.4,<8",
"symfony/stopwatch": ">=5.4,<8"
"symfony/stopwatch": ">=5.4,<8",
"symfony/twig-bundle": ">=5.4,<8"
},
"autoload": {
"psr-4": {
Original file line number Diff line number Diff line change
@@ -19,7 +19,9 @@ public function load(array $configs, ContainerBuilder $container): void
StateMachine::class => (new Definition(StateMachine::class))
->setArgument('$dispatcher', new Reference('event_dispatcher'))
->setPublic(true),
TwigExtension::class => new Definition(TwigExtension::class),
TwigExtension::class => (new Definition(TwigExtension::class))
->setArgument('$stateMachine', new Reference(StateMachine::class))
->addTag('twig.extension'),
]
);
}
1 change: 1 addition & 0 deletions tests/Extension/Symfony/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ public function registerBundles(): iterable
{
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Finite\Extension\Symfony\Bundle\FiniteBundle(),
];
}
5 changes: 5 additions & 0 deletions tests/Extension/Symfony/ServiceTest.php
Original file line number Diff line number Diff line change
@@ -4,11 +4,14 @@
namespace Finite\Tests\Extension\Symfony;

use Finite\Event\CanTransitionEvent;
use Finite\Extension\Twig\FiniteExtension;
use Finite\StateMachine;
use Finite\Tests\Extension\Symfony\Fixtures\Model\Document;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;

class ServiceTest extends KernelTestCase
{
@@ -18,6 +21,8 @@ public function test_services_are_registered(): void

$this->assertInstanceOf(StateMachine::class, $container->get(StateMachine::class));
$this->assertInstanceOf(EventDispatcherInterface::class, $container->get(StateMachine::class)->getDispatcher());

$this->assertArrayHasKey(FiniteExtension::class, $container->get('twig')->getExtensions());
}

public function test_it_uses_the_symfony_dispatcher(): void

0 comments on commit 3238aa5

Please sign in to comment.