Skip to content

Commit 9570303

Browse files
committed
another tests fixed
1 parent a8d2c4b commit 9570303

File tree

9 files changed

+64
-142
lines changed

9 files changed

+64
-142
lines changed

composer.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon"
1010
},
1111
"require": {
12-
"php": "^7.4|^8.0",
12+
"php": "^8.1",
1313

1414
"ext-amqp": "^1.9.3|^2.0.0",
1515
"ext-gearman": "^2.0",
@@ -53,18 +53,18 @@
5353
"phpunit/phpunit": "^9.5",
5454
"phpstan/phpstan": "^0.12",
5555
"queue-interop/queue-spec": "^0.6.2",
56-
"symfony/browser-kit": "^5.4|^6.0",
57-
"symfony/config": "^5.4|^6.0",
58-
"symfony/process": "^5.4|^6.0",
59-
"symfony/console": "^5.4|^6.0",
60-
"symfony/dependency-injection": "^5.4|^6.0",
61-
"symfony/event-dispatcher": "^5.4|^6.0",
62-
"symfony/expression-language": "^5.4|^6.0",
63-
"symfony/http-kernel": "^5.4|^6.0",
64-
"symfony/filesystem": "^5.4|^6.0",
65-
"symfony/framework-bundle": "^5.4|^6.0",
66-
"symfony/validator": "^5.4|^6.0",
67-
"symfony/yaml": "^5.4|^6.0",
56+
"symfony/browser-kit": "^6.2|^7.0",
57+
"symfony/config": "^6.2|^7.0",
58+
"symfony/process": "^6.2|^7.0",
59+
"symfony/console": "^6.2|^7.0",
60+
"symfony/dependency-injection": "^6.2|^7.0",
61+
"symfony/event-dispatcher": "^6.2|^7.0",
62+
"symfony/expression-language": "^6.2|^7.0",
63+
"symfony/http-kernel": "^^6.2|^7.0",
64+
"symfony/filesystem": "^6.2|^7.0",
65+
"symfony/framework-bundle": "^^6.2|^7.0",
66+
"symfony/validator": "^6.2|^7.0",
67+
"symfony/yaml": "^6.2|^7.0",
6868
"empi89/php-amqp-stubs": "*@dev",
6969
"doctrine/doctrine-bundle": "^2.3.2",
7070
"doctrine/mongodb-odm-bundle": "^3.5|^4.3|^5.0",

pkg/async-event-dispatcher/ContainerAwareRegistry.php

+11-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Enqueue\AsyncEventDispatcher;
44

5-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
6-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
5+
use Psr\Container\ContainerInterface;
76

8-
class ContainerAwareRegistry implements Registry, ContainerAwareInterface
7+
class ContainerAwareRegistry implements Registry
98
{
10-
use ContainerAwareTrait;
9+
/**
10+
* @var ContainerInterface
11+
*/
12+
private $container;
1113

1214
/**
1315
* @var string[]
@@ -23,23 +25,21 @@ class ContainerAwareRegistry implements Registry, ContainerAwareInterface
2325
* @param string[] $eventsMap [eventName => transformerName]
2426
* @param string[] $transformersMap [transformerName => transformerServiceId]
2527
*/
26-
public function __construct(array $eventsMap, array $transformersMap)
28+
public function __construct(array $eventsMap, array $transformersMap, ContainerInterface $container)
2729
{
2830
$this->eventsMap = $eventsMap;
2931
$this->transformersMap = $transformersMap;
32+
$this->container = $container;
3033
}
3134

32-
/**
33-
* {@inheritdoc}
34-
*/
3535
public function getTransformerNameForEvent($eventName)
3636
{
3737
$transformerName = null;
3838
if (array_key_exists($eventName, $this->eventsMap)) {
3939
$transformerName = $this->eventsMap[$eventName];
4040
} else {
4141
foreach ($this->eventsMap as $eventNamePattern => $name) {
42-
if ('/' != $eventNamePattern[0]) {
42+
if ('/' !== $eventNamePattern[0]) {
4343
continue;
4444
}
4545

@@ -58,9 +58,6 @@ public function getTransformerNameForEvent($eventName)
5858
return $transformerName;
5959
}
6060

61-
/**
62-
* {@inheritdoc}
63-
*/
6461
public function getTransformer($name)
6562
{
6663
if (false == array_key_exists($name, $this->transformersMap)) {
@@ -69,12 +66,8 @@ public function getTransformer($name)
6966

7067
$transformer = $this->container->get($this->transformersMap[$name]);
7168

72-
if (false == $transformer instanceof EventTransformer) {
73-
throw new \LogicException(sprintf(
74-
'The container must return instance of %s but got %s',
75-
EventTransformer::class,
76-
is_object($transformer) ? get_class($transformer) : gettype($transformer)
77-
));
69+
if (false == $transformer instanceof EventTransformer) {
70+
throw new \LogicException(sprintf('The container must return instance of %s but got %s', EventTransformer::class, is_object($transformer) ? $transformer::class : gettype($transformer)));
7871
}
7972

8073
return $transformer;

pkg/async-event-dispatcher/DependencyInjection/Configuration.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
class Configuration implements ConfigurationInterface
99
{
10-
/**
11-
* {@inheritdoc}
12-
*/
13-
public function getConfigTreeBuilder()
10+
public function getConfigTreeBuilder(): TreeBuilder
1411
{
1512
if (method_exists(TreeBuilder::class, 'getRootNode')) {
1613
$tb = new TreeBuilder('enqueue_async_event_dispatcher');

pkg/async-event-dispatcher/Resources/config/services.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ services:
88
enqueue.events.registry:
99
class: 'Enqueue\AsyncEventDispatcher\ContainerAwareRegistry'
1010
public: false
11-
arguments: [[], []]
12-
calls:
13-
- ['setContainer', ['@service_container']]
11+
arguments: [[], [], '@service_container']
1412

1513
enqueue.events.async_listener:
1614
class: 'Enqueue\AsyncEventDispatcher\AsyncListener'

pkg/async-event-dispatcher/Tests/ContainerAwareRegistryTest.php

+14-24
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,25 @@ public function testShouldImplementRegistryInterface()
2020
$this->assertClassImplements(Registry::class, ContainerAwareRegistry::class);
2121
}
2222

23-
public function testCouldBeConstructedWithEventsMapAndTransformersMapAsArguments()
24-
{
25-
new ContainerAwareRegistry([], []);
26-
}
27-
28-
public function testShouldSetContainerToContainerProperty()
23+
public function testShouldAllowGetTransportNameByEventName()
2924
{
3025
$container = new Container();
3126

32-
$registry = new ContainerAwareRegistry([], []);
33-
34-
$registry->setContainer($container);
35-
36-
$this->assertAttributeSame($container, 'container', $registry);
37-
}
38-
39-
public function testShouldAllowGetTransportNameByEventName()
40-
{
4127
$registry = new ContainerAwareRegistry([
42-
'fooEvent' => 'fooTrans',
43-
], []);
28+
'fooEvent' => 'fooTrans',
29+
], [], $container);
4430

4531
$this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent'));
4632
}
4733

4834
public function testShouldAllowDefineTransportNameAsRegExpPattern()
4935
{
36+
$container = new Container();
37+
5038
$registry = new ContainerAwareRegistry([
5139
'/.*/' => 'fooRegExpTrans',
5240
'fooEvent' => 'fooTrans',
53-
], []);
41+
], [], $container);
5442

5543
// guard
5644
$this->assertEquals('fooTrans', $registry->getTransformerNameForEvent('fooEvent'));
@@ -60,9 +48,11 @@ public function testShouldAllowDefineTransportNameAsRegExpPattern()
6048

6149
public function testThrowIfNotSupportedEventGiven()
6250
{
51+
$container = new Container();
52+
6353
$registry = new ContainerAwareRegistry([
6454
'fooEvent' => 'fooTrans',
65-
], []);
55+
], [], $container);
6656

6757
$this->expectException(\LogicException::class);
6858
$this->expectExceptionMessage('There is no transformer registered for the given event fooNotSupportedEvent');
@@ -71,9 +61,11 @@ public function testThrowIfNotSupportedEventGiven()
7161

7262
public function testThrowIfThereIsNoRegisteredTransformerWithSuchName()
7363
{
64+
$container = new Container();
65+
7466
$registry = new ContainerAwareRegistry([], [
7567
'fooTrans' => 'foo_trans_id',
76-
]);
68+
], $container);
7769

7870
$this->expectException(\LogicException::class);
7971
$this->expectExceptionMessage('There is no transformer named fooNotRegisteredName');
@@ -87,8 +79,7 @@ public function testThrowIfContainerReturnsServiceNotInstanceOfEventTransformer(
8779

8880
$registry = new ContainerAwareRegistry([], [
8981
'fooTrans' => 'foo_trans_id',
90-
]);
91-
$registry->setContainer($container);
82+
], $container);
9283

9384
$this->expectException(\LogicException::class);
9485
$this->expectExceptionMessage('The container must return instance of Enqueue\AsyncEventDispatcher\EventTransformer but got stdClass');
@@ -104,8 +95,7 @@ public function testShouldReturnEventTransformer()
10495

10596
$registry = new ContainerAwareRegistry([], [
10697
'fooTrans' => 'foo_trans_id',
107-
]);
108-
$registry->setContainer($container);
98+
], $container);
10999

110100
$this->assertSame($eventTransformerMock, $registry->getTransformer('fooTrans'));
111101
}

pkg/job-queue/Tests/Functional/Entity/Job.php

+17-67
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,47 @@
66
use Doctrine\ORM\Mapping as ORM;
77
use Enqueue\JobQueue\Job as BaseJob;
88

9-
/**
10-
* @ORM\Entity
11-
* @ORM\Table(name="enqueue_job_queue")
12-
*/
9+
#[ORM\Entity]
10+
#[ORM\Table(name: 'enqueue_job_queue')]
1311
class Job extends BaseJob
1412
{
15-
/**
16-
* @var int
17-
*
18-
* @ORM\Column(name="id", type="integer")
19-
* @ORM\Id
20-
* @ORM\GeneratedValue(strategy="AUTO")
21-
*/
13+
#[ORM\Column(name: 'id', type: 'integer')]
14+
#[ORM\Id]
15+
#[ORM\GeneratedValue(strategy: 'AUTO')]
2216
protected $id;
2317

24-
/**
25-
* @var string
26-
*
27-
* @ORM\Column(name="owner_id", type="string", nullable=true)
28-
*/
18+
#[ORM\Column(name: 'owner_id', type: 'string', nullable: true)]
2919
protected $ownerId;
3020

31-
/**
32-
* @var string
33-
*
34-
* @ORM\Column(name="name", type="string", nullable=false)
35-
*/
21+
#[ORM\Column(name: 'name', type: 'string', nullable: false)]
3622
protected $name;
3723

38-
/**
39-
* @var string
40-
*
41-
* @ORM\Column(name="status", type="string", nullable=false)
42-
*/
24+
#[ORM\Column(name: 'status', type: 'string', nullable: false)]
4325
protected $status;
4426

45-
/**
46-
* @var bool
47-
*
48-
* @ORM\Column(name="interrupted", type="boolean")
49-
*/
27+
#[ORM\Column(name: 'interrupted', type: 'boolean')]
5028
protected $interrupted;
5129

52-
/**
53-
* @var bool;
54-
*
55-
* @ORM\Column(name="`unique`", type="boolean")
56-
*/
30+
#[ORM\Column(name: '`unique`', type: 'boolean')]
5731
protected $unique;
5832

59-
/**
60-
* @var Job
61-
*
62-
* @ORM\ManyToOne(targetEntity="Job", inversedBy="childJobs")
63-
* @ORM\JoinColumn(name="root_job_id", referencedColumnName="id", onDelete="CASCADE")
64-
*/
33+
#[ORM\ManyToOne(targetEntity: 'Job', inversedBy: 'childJobs')]
34+
#[ORM\JoinColumn(name: 'root_job_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
6535
protected $rootJob;
6636

67-
/**
68-
* @var Job[]
69-
*
70-
* @ORM\OneToMany(targetEntity="Job", mappedBy="rootJob")
71-
*/
37+
#[ORM\OneToMany(mappedBy: 'rootJob', targetEntity: 'Job')]
7238
protected $childJobs;
7339

74-
/**
75-
* @var \DateTime
76-
*
77-
* @ORM\Column(name="created_at", type="datetime", nullable=false)
78-
*/
40+
#[ORM\Column(name: 'created_at', type: 'datetime', nullable: false)]
7941
protected $createdAt;
8042

81-
/**
82-
* @var \DateTime
83-
*
84-
* @ORM\Column(name="started_at", type="datetime", nullable=true)
85-
*/
43+
#[ORM\Column(name: 'started_at', type: 'datetime', nullable: true)]
8644
protected $startedAt;
8745

88-
/**
89-
* @var \DateTime
90-
*
91-
* @ORM\Column(name="stopped_at", type="datetime", nullable=true)
92-
*/
46+
#[ORM\Column(name: 'stopped_at', type: 'datetime', nullable: true)]
9347
protected $stoppedAt;
9448

95-
/**
96-
* @var array
97-
*
98-
* @ORM\Column(name="data", type="json", nullable=true)
99-
*/
49+
#[ORM\Column(name: 'data', type: 'json', nullable: true)]
10050
protected $data;
10151

10252
public function __construct()

pkg/job-queue/Tests/Functional/Entity/JobUnique.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@
44

55
use Doctrine\ORM\Mapping as ORM;
66

7-
/**
8-
* @ORM\Entity
9-
* @ORM\Table(name="enqueue_job_queue_unique")
10-
*/
7+
#[ORM\Entity]
8+
#[ORM\Table(name: 'enqueue_job_queue_unique')]
119
class JobUnique
1210
{
13-
/**
14-
* @ORM\Id
15-
* @ORM\Column(name="name", type="string", nullable=false)
16-
*/
11+
#[ORM\Id]
12+
#[ORM\Column(name: 'name', type: 'string', nullable: false)]
1713
protected $name;
1814
}

pkg/job-queue/Tests/Functional/app/AppKernel.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
4-
53
use Symfony\Component\Config\Loader\LoaderInterface;
64
use Symfony\Component\HttpKernel\Kernel;
75

@@ -10,8 +8,8 @@ class AppKernel extends Kernel
108
public function registerBundles(): iterable
119
{
1210
$bundles = [
13-
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
14-
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
11+
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
12+
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
1513
];
1614

1715
return $bundles;

pkg/job-queue/Tests/Functional/app/config/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ doctrine:
2525
mappings:
2626
TestEntity:
2727
mapping: true
28-
type: annotation
28+
type: attribute
2929
dir: '%kernel.project_dir%/Tests/Functional/Entity'
3030
alias: 'EnqueueJobQueue'
3131
prefix: 'Enqueue\JobQueue\Tests\Functional\Entity'

0 commit comments

Comments
 (0)