Skip to content

Commit a4e4b09

Browse files
committed
fix test
1 parent 403e5f0 commit a4e4b09

File tree

4 files changed

+96
-68
lines changed

4 files changed

+96
-68
lines changed

src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Symfony\Component\Messenger\MessageBusInterface;
2828
use Symfony\Component\Messenger\RoutableMessageBus;
2929
use Symfony\Component\Messenger\Stamp\BusNameStamp;
30-
use Symfony\Component\Messenger\Tests\ResettableDummyReceiver;
30+
use Symfony\Component\Messenger\Tests\Fixtures\ResettableDummyReceiver;
3131
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
3232

3333
class ConsumeMessagesCommandTest extends TestCase
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Tests\Fixtures;
13+
14+
use Symfony\Component\Messenger\Envelope;
15+
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
16+
17+
class DummyReceiver implements ReceiverInterface
18+
{
19+
private $deliveriesOfEnvelopes;
20+
private $acknowledgedEnvelopes;
21+
private $acknowledgeCount = 0;
22+
private $rejectCount = 0;
23+
24+
/**
25+
* @param Envelope[][] $deliveriesOfEnvelopes
26+
*/
27+
public function __construct(array $deliveriesOfEnvelopes)
28+
{
29+
$this->deliveriesOfEnvelopes = $deliveriesOfEnvelopes;
30+
}
31+
32+
public function get(): iterable
33+
{
34+
$val = array_shift($this->deliveriesOfEnvelopes);
35+
36+
return $val ?? [];
37+
}
38+
39+
public function ack(Envelope $envelope): void
40+
{
41+
++$this->acknowledgeCount;
42+
$this->acknowledgedEnvelopes[] = $envelope;
43+
}
44+
45+
public function reject(Envelope $envelope): void
46+
{
47+
++$this->rejectCount;
48+
}
49+
50+
public function getAcknowledgeCount(): int
51+
{
52+
return $this->acknowledgeCount;
53+
}
54+
55+
public function getRejectCount(): int
56+
{
57+
return $this->rejectCount;
58+
}
59+
60+
public function getAcknowledgedEnvelopes(): array
61+
{
62+
return $this->acknowledgedEnvelopes;
63+
}
64+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Tests\Fixtures;
13+
14+
use Symfony\Contracts\Service\ResetInterface;
15+
16+
class ResettableDummyReceiver extends DummyReceiver implements ResetInterface
17+
{
18+
private $hasBeenReset = false;
19+
20+
public function reset()
21+
{
22+
$this->hasBeenReset = true;
23+
}
24+
25+
public function hasBeenReset(): bool
26+
{
27+
return $this->hasBeenReset;
28+
}
29+
}

src/Symfony/Component/Messenger/Tests/WorkerTest.php

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@
3838
use Symfony\Component\Messenger\Stamp\SentStamp;
3939
use Symfony\Component\Messenger\Stamp\StampInterface;
4040
use Symfony\Component\Messenger\Tests\Fixtures\DummyMessage;
41+
use Symfony\Component\Messenger\Tests\Fixtures\DummyReceiver;
42+
use Symfony\Component\Messenger\Tests\Fixtures\ResettableDummyReceiver;
4143
use Symfony\Component\Messenger\Transport\Receiver\QueueReceiverInterface;
4244
use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface;
4345
use Symfony\Component\Messenger\Worker;
4446
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
45-
use Symfony\Contracts\Service\ResetInterface;
4647

4748
/**
4849
* @group time-sensitive
@@ -513,57 +514,6 @@ public function testFlushBatchOnStop()
513514
}
514515
}
515516

516-
class DummyReceiver implements ReceiverInterface
517-
{
518-
private $deliveriesOfEnvelopes;
519-
private $acknowledgedEnvelopes;
520-
private $rejectedEnvelopes;
521-
private $acknowledgeCount = 0;
522-
private $rejectCount = 0;
523-
524-
/**
525-
* @param Envelope[][] $deliveriesOfEnvelopes
526-
*/
527-
public function __construct(array $deliveriesOfEnvelopes)
528-
{
529-
$this->deliveriesOfEnvelopes = $deliveriesOfEnvelopes;
530-
}
531-
532-
public function get(): iterable
533-
{
534-
$val = array_shift($this->deliveriesOfEnvelopes);
535-
536-
return $val ?? [];
537-
}
538-
539-
public function ack(Envelope $envelope): void
540-
{
541-
++$this->acknowledgeCount;
542-
$this->acknowledgedEnvelopes[] = $envelope;
543-
}
544-
545-
public function reject(Envelope $envelope): void
546-
{
547-
++$this->rejectCount;
548-
$this->rejectedEnvelopes[] = $envelope;
549-
}
550-
551-
public function getAcknowledgeCount(): int
552-
{
553-
return $this->acknowledgeCount;
554-
}
555-
556-
public function getRejectCount(): int
557-
{
558-
return $this->rejectCount;
559-
}
560-
561-
public function getAcknowledgedEnvelopes(): array
562-
{
563-
return $this->acknowledgedEnvelopes;
564-
}
565-
}
566-
567517
class DummyQueueReceiver extends DummyReceiver implements QueueReceiverInterface
568518
{
569519
public function getFromQueues(array $queueNames): iterable
@@ -597,18 +547,3 @@ private function process(array $jobs): void
597547
}
598548
}
599549
}
600-
601-
class ResettableDummyReceiver extends DummyReceiver implements ResetInterface
602-
{
603-
private $hasBeenReset = false;
604-
605-
public function reset()
606-
{
607-
$this->hasBeenReset = true;
608-
}
609-
610-
public function hasBeenReset(): bool
611-
{
612-
return $this->hasBeenReset;
613-
}
614-
}

0 commit comments

Comments
 (0)