Skip to content

Commit c353ce6

Browse files
committed
Ensure that the bundle works even without the symfony/twig-bundle package installed
1 parent 9ae4370 commit c353ce6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-${{ matrix.dependencies }}-
105105

106106
- name: Remove optional packages
107-
run: composer remove doctrine/dbal doctrine/doctrine-bundle symfony/messenger --dev --no-update
107+
run: composer remove doctrine/dbal doctrine/doctrine-bundle symfony/messenger symfony/twig-bundle --dev --no-update
108108

109109
- name: Install highest dependencies
110110
run: composer update --no-progress --no-interaction --prefer-dist

tests/Tracing/Twig/TwigTracingExtensionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Sentry\State\HubInterface;
1111
use Sentry\Tracing\Transaction;
1212
use Sentry\Tracing\TransactionContext;
13+
use Symfony\Bundle\TwigBundle\TwigBundle;
1314
use Twig\Profiler\Profile;
1415

1516
final class TwigTracingExtensionTest extends TestCase
@@ -24,6 +25,13 @@ final class TwigTracingExtensionTest extends TestCase
2425
*/
2526
private $listener;
2627

28+
public static function setUpBeforeClass(): void
29+
{
30+
if (!self::isTwigBundlePackageInstalled()) {
31+
self::markTestSkipped('This test requires the "symfony/twig-bundle" Composer package to be installed.');
32+
}
33+
}
34+
2735
protected function setUp(): void
2836
{
2937
$this->hub = $this->createMock(HubInterface::class);
@@ -113,4 +121,9 @@ public function testLeaveDoesNothingIfSpanDoesNotExistsForProfile(): void
113121

114122
$this->listener->leave(new Profile('main', Profile::TEMPLATE));
115123
}
124+
125+
private static function isTwigBundlePackageInstalled(): bool
126+
{
127+
return class_exists(TwigBundle::class);
128+
}
116129
}

0 commit comments

Comments
 (0)