Skip to content

Commit c536da5

Browse files
committed
Add support for Symfony 6
1 parent 9a0f7cb commit c536da5

File tree

11 files changed

+247
-47
lines changed

11 files changed

+247
-47
lines changed

Tests/Functional/App/AppKernel.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
class AppKernel extends Kernel
99
{
10-
/**
11-
* @return array
12-
*/
13-
public function registerBundles()
10+
public function registerBundles(): iterable
1411
{
1512
$bundles = [
1613
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
@@ -21,28 +18,28 @@ public function registerBundles()
2118
return $bundles;
2219
}
2320

24-
/**
25-
* @return string
26-
*/
27-
public function getCacheDir()
21+
public function getCacheDir(): string
2822
{
2923
return sys_get_temp_dir().'/EnqueueBundle/cache';
3024
}
3125

32-
/**
33-
* @return string
34-
*/
35-
public function getLogDir()
26+
public function getLogDir(): string
3627
{
3728
return sys_get_temp_dir().'/EnqueueBundle/cache/logs';
3829
}
3930

4031
public function registerContainerConfiguration(LoaderInterface $loader)
4132
{
33+
if (self::VERSION_ID < 60000) {
34+
$loader->load(__DIR__.'/config/config-sf5.yml');
35+
36+
return;
37+
}
38+
4239
$loader->load(__DIR__.'/config/config.yml');
4340
}
4441

45-
protected function getContainerClass()
42+
protected function getContainerClass(): string
4643
{
4744
return parent::getContainerClass().'BundleDefault';
4845
}

Tests/Functional/App/CustomAppKernel.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public function setEnqueueConfig(array $config)
3838
$fs->mkdir(sys_get_temp_dir().'/EnqueueBundleCustom/cache/'.$this->enqueueConfigId);
3939
}
4040

41-
/**
42-
* @return array
43-
*/
44-
public function registerBundles()
41+
public function registerBundles(): iterable
4542
{
4643
$bundles = [
4744
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
@@ -52,23 +49,17 @@ public function registerBundles()
5249
return $bundles;
5350
}
5451

55-
/**
56-
* @return string
57-
*/
58-
public function getCacheDir()
52+
public function getCacheDir(): string
5953
{
6054
return sys_get_temp_dir().'/EnqueueBundleCustom/cache/'.$this->enqueueConfigId;
6155
}
6256

63-
/**
64-
* @return string
65-
*/
66-
public function getLogDir()
57+
public function getLogDir(): string
6758
{
6859
return sys_get_temp_dir().'/EnqueueBundleCustom/cache/logs/'.$this->enqueueConfigId;
6960
}
7061

71-
protected function getContainerClass()
62+
protected function getContainerClass(): string
7263
{
7364
return parent::getContainerClass().'Custom'.$this->enqueueConfigId;
7465
}
@@ -78,7 +69,11 @@ protected function getContainerClass()
7869
*/
7970
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
8071
{
81-
$loader->load(__DIR__.'/config/custom-config.yml');
72+
if (self::VERSION_ID < 60000) {
73+
$loader->load(__DIR__.'/config/custom-config-sf5.yml');
74+
} else {
75+
$loader->load(__DIR__.'/config/custom-config.yml');
76+
}
8277

8378
$c->loadFromExtension('enqueue', $this->enqueueConfig);
8479
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
parameters:
2+
locale: 'en'
3+
secret: 'ThisTokenIsNotSoSecretChangeIt'
4+
5+
6+
framework:
7+
#esi: ~
8+
#translator: { fallback: "%locale%" }
9+
test: ~
10+
assets: false
11+
session:
12+
# the only option incompatible with Symfony 6
13+
storage_id: session.storage.mock_file
14+
secret: '%secret%'
15+
router: { resource: '%kernel.project_dir%/config/routing.yml' }
16+
default_locale: '%locale%'
17+
18+
doctrine:
19+
dbal:
20+
url: "%env(DOCTRINE_DSN)%"
21+
driver: pdo_mysql
22+
charset: UTF8
23+
24+
enqueue:
25+
default:
26+
transport: 'null:'
27+
client:
28+
traceable_producer: true
29+
job: true
30+
async_events: true
31+
async_commands:
32+
enabled: true
33+
timeout: 60
34+
command_name: ~
35+
queue_name: ~
36+
37+
services:
38+
test_enqueue.client.default.traceable_producer:
39+
alias: 'enqueue.client.default.traceable_producer'
40+
public: true
41+
42+
test_enqueue.transport.default.queue_consumer:
43+
alias: 'enqueue.transport.default.queue_consumer'
44+
public: true
45+
46+
test_enqueue.client.default.queue_consumer:
47+
alias: 'enqueue.client.default.queue_consumer'
48+
public: true
49+
50+
test_enqueue.transport.default.rpc_client:
51+
alias: 'enqueue.transport.default.rpc_client'
52+
public: true
53+
54+
test_enqueue.client.default.producer:
55+
alias: 'enqueue.client.default.producer'
56+
public: true
57+
58+
test_enqueue.client.default.spool_producer:
59+
alias: 'enqueue.client.default.spool_producer'
60+
public: true
61+
62+
test_Enqueue\Client\ProducerInterface:
63+
alias: 'Enqueue\Client\ProducerInterface'
64+
public: true
65+
66+
test_enqueue.client.default.driver:
67+
alias: 'enqueue.client.default.driver'
68+
public: true
69+
70+
test_enqueue.transport.default.context:
71+
alias: 'enqueue.transport.default.context'
72+
public: true
73+
74+
test_enqueue.client.consume_command:
75+
alias: 'enqueue.client.consume_command'
76+
public: true
77+
78+
test.enqueue.client.routes_command:
79+
alias: 'enqueue.client.routes_command'
80+
public: true
81+
82+
test.enqueue.events.async_processor:
83+
alias: 'enqueue.events.async_processor'
84+
public: true
85+
86+
test_async_listener:
87+
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncListener'
88+
public: true
89+
tags:
90+
- { name: 'kernel.event_listener', async: true, event: 'test_async', method: 'onEvent' }
91+
92+
test_command_subscriber_processor:
93+
class: 'Enqueue\Bundle\Tests\Functional\App\TestCommandSubscriberProcessor'
94+
public: true
95+
tags:
96+
- { name: 'enqueue.command_subscriber', client: 'default' }
97+
98+
test_topic_subscriber_processor:
99+
class: 'Enqueue\Bundle\Tests\Functional\App\TestTopicSubscriberProcessor'
100+
public: true
101+
tags:
102+
- { name: 'enqueue.topic_subscriber', client: 'default' }
103+
104+
test_exclusive_command_subscriber_processor:
105+
class: 'Enqueue\Bundle\Tests\Functional\App\TestExclusiveCommandSubscriberProcessor'
106+
public: true
107+
tags:
108+
- { name: 'enqueue.command_subscriber', client: 'default' }
109+
110+
test_async_subscriber:
111+
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncSubscriber'
112+
public: true
113+
tags:
114+
- { name: 'kernel.event_subscriber', async: true }
115+
116+
test_async_event_transformer:
117+
class: 'Enqueue\Bundle\Tests\Functional\App\TestAsyncEventTransformer'
118+
public: true
119+
arguments:
120+
- '@enqueue.transport.default.context'
121+
tags:
122+
- {name: 'enqueue.event_transformer', eventName: 'test_async', transformerName: 'test_async' }
123+
- {name: 'enqueue.event_transformer', eventName: 'test_async_subscriber', transformerName: 'test_async' }
124+
125+
# overwrite async listener with one based on client producer. so we can use traceable producer.
126+
enqueue.events.async_listener:
127+
class: 'Enqueue\Bundle\Tests\Functional\App\AsyncListener'
128+
public: true
129+
arguments: ['@enqueue.client.default.producer', '@enqueue.events.registry']

Tests/Functional/App/config/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ framework:
99
test: ~
1010
assets: false
1111
session:
12-
storage_id: session.storage.mock_file
12+
storage_factory_id: session.storage.factory.mock_file
1313
secret: '%secret%'
1414
router: { resource: '%kernel.project_dir%/config/routing.yml' }
1515
default_locale: '%locale%'
@@ -126,3 +126,6 @@ services:
126126
class: 'Enqueue\Bundle\Tests\Functional\App\AsyncListener'
127127
public: true
128128
arguments: ['@enqueue.client.default.producer', '@enqueue.events.registry']
129+
130+
locale_aware_listener:
131+
public: true
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
parameters:
2+
locale: 'en'
3+
secret: 'ThisTokenIsNotSoSecretChangeIt'
4+
5+
framework:
6+
#esi: ~
7+
#translator: { fallback: "%locale%" }
8+
test: ~
9+
assets: false
10+
session:
11+
# the only option incompatible with Symfony 6
12+
storage_id: session.storage.mock_file
13+
secret: '%secret%'
14+
router: { resource: '%kernel.project_dir%/config/routing.yml' }
15+
default_locale: '%locale%'
16+
17+
doctrine:
18+
dbal:
19+
connections:
20+
custom:
21+
url: "%env(DOCTRINE_DSN)%"
22+
driver: pdo_mysql
23+
charset: UTF8
24+
25+
services:
26+
test_enqueue.client.default.driver:
27+
alias: 'enqueue.client.default.driver'
28+
public: true
29+
30+
test_enqueue.client.default.producer:
31+
alias: 'enqueue.client.default.producer'
32+
public: true
33+
34+
test_enqueue.client.default.lazy_producer:
35+
alias: 'enqueue.client.default.lazy_producer'
36+
public: true
37+
38+
test_enqueue.transport.default.context:
39+
alias: 'enqueue.transport.default.context'
40+
public: true
41+
42+
test_enqueue.transport.consume_command:
43+
alias: 'enqueue.transport.consume_command'
44+
public: true
45+
46+
test_enqueue.client.consume_command:
47+
alias: 'enqueue.client.consume_command'
48+
public: true
49+
50+
test_enqueue.client.produce_command:
51+
alias: 'enqueue.client.produce_command'
52+
public: true
53+
54+
test_enqueue.client.setup_broker_command:
55+
alias: 'enqueue.client.setup_broker_command'
56+
public: true
57+
58+
test.message.processor:
59+
class: 'Enqueue\Bundle\Tests\Functional\TestProcessor'
60+
public: true
61+
tags:
62+
- { name: 'enqueue.topic_subscriber', client: 'default' }
63+
- { name: 'enqueue.transport.processor', transport: 'default' }
64+
65+
test.message.command_processor:
66+
class: 'Enqueue\Bundle\Tests\Functional\TestCommandProcessor'
67+
public: true
68+
tags:
69+
- { name: 'enqueue.command_subscriber', client: 'default' }
70+
71+
test.sqs_client:
72+
public: true
73+
class: 'Aws\Sqs\SqsClient'
74+
arguments:
75+
-
76+
endpoint: '%env(AWS_SQS_ENDPOINT)%'
77+
region: '%env(AWS_SQS_REGION)%'
78+
version: '%env(AWS_SQS_VERSION)%'
79+
credentials:
80+
key: '%env(AWS_SQS_KEY)%'
81+
secret: '%env(AWS_SQS_SECRET)%'
82+
83+
test.sqs_custom_connection_factory_factory:
84+
class: 'Enqueue\Bundle\Tests\Functional\App\SqsCustomConnectionFactoryFactory'
85+
arguments: ['@service_container']

Tests/Functional/App/config/custom-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ framework:
88
test: ~
99
assets: false
1010
session:
11-
storage_id: session.storage.mock_file
11+
storage_factory_id: session.storage.factory.mock_file
1212
secret: '%secret%'
1313
router: { resource: '%kernel.project_dir%/config/routing.yml' }
1414
default_locale: '%locale%'

Tests/Functional/LazyProducerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@ public function testShouldAllowGetLazyProducerWithoutError()
4747
$producer->sendEvent('foo', 'foo');
4848
}
4949

50-
/**
51-
* @return string
52-
*/
53-
public static function getKernelClass()
50+
public static function getKernelClass(): string
5451
{
5552
include_once __DIR__.'/App/CustomAppKernel.php';
5653

Tests/Functional/UseCasesTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class UseCasesTest extends WebTestCase
2020
{
21-
const RECEIVE_TIMEOUT = 500;
21+
private const RECEIVE_TIMEOUT = 500;
2222

2323
protected function setUp(): void
2424
{
@@ -360,10 +360,7 @@ public function testTransportConsumeCommandShouldConsumeOneMessage()
360360
$this->assertEquals($expectedBody, $processor->message->getBody());
361361
}
362362

363-
/**
364-
* @return string
365-
*/
366-
public static function getKernelClass()
363+
public static function getKernelClass(): string
367364
{
368365
include_once __DIR__.'/App/CustomAppKernel.php';
369366

Tests/Functional/WebTestCase.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ protected function tearDown(): void
3939
static::$client = null;
4040
}
4141

42-
/**
43-
* @return string
44-
*/
45-
public static function getKernelClass()
42+
public static function getKernelClass(): string
4643
{
4744
include_once __DIR__.'/App/AppKernel.php';
4845

0 commit comments

Comments
 (0)