Skip to content

Commit 1d0c08e

Browse files
committed
register job compiler pass
1 parent b56365a commit 1d0c08e

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

QuartzBundle.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
namespace Quartz\Bundle;
44

5+
use Quartz\Bridge\DI\QuartzJobCompilerPass;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
57
use Symfony\Component\HttpKernel\Bundle\Bundle;
68

79
class QuartzBundle extends Bundle
810
{
11+
public function build(ContainerBuilder $container)
12+
{
13+
$container->addCompilerPass(new QuartzJobCompilerPass());
14+
}
915
}

Tests/QuartzBundleTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Quartz\Bundle\Tests;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Quartz\Bridge\DI\QuartzJobCompilerPass;
7+
use Quartz\Bundle\QuartzBundle;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\HttpKernel\Bundle\Bundle;
10+
11+
class QuartzBundleTest extends TestCase
12+
{
13+
public function testShouldExtendBundleClass()
14+
{
15+
$this->assertInstanceOf(Bundle::class, new QuartzBundle());
16+
}
17+
18+
public function testShouldRegisterExpectedCompilerPasses()
19+
{
20+
$container = $this->createMock(ContainerBuilder::class);
21+
$container
22+
->expects($this->at(0))
23+
->method('addCompilerPass')
24+
->with($this->isInstanceOf(QuartzJobCompilerPass::class))
25+
;
26+
27+
$bundle = new QuartzBundle();
28+
$bundle->build($container);
29+
}
30+
}

0 commit comments

Comments
 (0)