Skip to content

Commit d09af90

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

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Sentry\State\HubInterface;
1111
use Sentry\Tracing\Transaction;
1212
use Sentry\Tracing\TransactionContext;
13-
use Twig\Profiler\Profile;
13+
use Symfony\Bundle\TwigBundle\TwigBundle;
1414

1515
final class TwigTracingExtensionTest extends TestCase
1616
{
@@ -24,6 +24,13 @@ final class TwigTracingExtensionTest extends TestCase
2424
*/
2525
private $listener;
2626

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

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

0 commit comments

Comments
 (0)