forked from php-enqueue/enqueue-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayProcessorRegistryTest.php
56 lines (43 loc) · 1.55 KB
/
ArrayProcessorRegistryTest.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
<?php
namespace Enqueue\Tests;
use Enqueue\ArrayProcessorRegistry;
use Enqueue\ProcessorRegistryInterface;
use Enqueue\Test\ClassExtensionTrait;
use Interop\Queue\Processor;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class ArrayProcessorRegistryTest extends TestCase
{
use ClassExtensionTrait;
public function testShouldImplementProcessorRegistryInterface()
{
$this->assertClassImplements(ProcessorRegistryInterface::class, ArrayProcessorRegistry::class);
}
public function testShouldThrowExceptionIfProcessorIsNotSet()
{
$registry = new ArrayProcessorRegistry();
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Processor was not found. processorName: "processor-name"');
$registry->get('processor-name');
}
public function testShouldAllowGetProcessorAddedViaConstructor()
{
$processor = $this->createProcessorMock();
$registry = new ArrayProcessorRegistry(['aFooName' => $processor]);
$this->assertSame($processor, $registry->get('aFooName'));
}
public function testShouldAllowGetProcessorAddedViaAddMethod()
{
$processor = $this->createProcessorMock();
$registry = new ArrayProcessorRegistry();
$registry->add('aFooName', $processor);
$this->assertSame($processor, $registry->get('aFooName'));
}
/**
* @return MockObject|Processor
*/
protected function createProcessorMock()
{
return $this->createMock(Processor::class);
}
}