Skip to content

Commit

Permalink
Ensure that the bundle works even without the symfony/twig-bundle pac…
Browse files Browse the repository at this point in the history
…kage installed
  • Loading branch information
ste93cry committed Feb 22, 2021
1 parent 9ae4370 commit d09af90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
restore-keys: ${{ runner.os }}-${{ matrix.php }}-composer-${{ matrix.dependencies }}-

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

- name: Install highest dependencies
run: composer update --no-progress --no-interaction --prefer-dist
Expand Down
14 changes: 13 additions & 1 deletion tests/Tracing/Twig/TwigTracingExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Sentry\State\HubInterface;
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Twig\Profiler\Profile;
use Symfony\Bundle\TwigBundle\TwigBundle;

final class TwigTracingExtensionTest extends TestCase
{
Expand All @@ -24,6 +24,13 @@ final class TwigTracingExtensionTest extends TestCase
*/
private $listener;

public static function setUpBeforeClass(): void
{
if (!self::isTwigBundlePackageInstalled()) {
self::markTestSkipped('This test requires the "symfony/twig-bundle" Composer package to be installed.');
}
}

protected function setUp(): void
{
$this->hub = $this->createMock(HubInterface::class);
Expand Down Expand Up @@ -113,4 +120,9 @@ public function testLeaveDoesNothingIfSpanDoesNotExistsForProfile(): void

$this->listener->leave(new Profile('main', Profile::TEMPLATE));
}

private static function isTwigBundlePackageInstalled(): bool
{
return class_exists(TwigBundle::class);
}
}

0 comments on commit d09af90

Please sign in to comment.