forked from php-enqueue/enqueue-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResetServicesExtensionTest.php
58 lines (50 loc) · 1.67 KB
/
ResetServicesExtensionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Enqueue\Bundle\Tests\Unit\Consumption\Extension;
use Doctrine\Persistence\ManagerRegistry;
use Enqueue\Bundle\Consumption\Extension\ResetServicesExtension;
use Enqueue\Consumption\Context\PostMessageReceived;
use Interop\Queue\Consumer;
use Interop\Queue\Context as InteropContext;
use Interop\Queue\Message;
use Interop\Queue\Processor;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
class ResetServicesExtensionTest extends TestCase
{
public function testItShouldResetServices()
{
$resetter = $this->createResetterMock();
$resetter
->expects($this->once())
->method('reset')
;
$context = $this->createContext();
$context->getLogger()
->expects($this->once())
->method('debug')
->with('[ResetServicesExtension] Resetting services.')
;
$extension = new ResetServicesExtension($resetter);
$extension->onPostMessageReceived($context);
}
protected function createContext(): PostMessageReceived
{
return new PostMessageReceived(
$this->createMock(InteropContext::class),
$this->createMock(Consumer::class),
$this->createMock(Message::class),
$this->createMock(Processor::class),
1,
$this->createMock(LoggerInterface::class)
);
}
/**
* @return MockObject|ManagerRegistry
*/
protected function createResetterMock(): ServicesResetter
{
return $this->createMock(ServicesResetter::class);
}
}