1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* This file is part of the daikon-cqrs/async-job project. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Daikon\Tests\AsyncJob\Worker; |
10
|
|
|
|
11
|
|
|
use Daikon\AsyncJob\Worker\WorkerInterface; |
12
|
|
|
use Daikon\AsyncJob\Worker\WorkerMap; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
final class WorkerMapTest extends TestCase |
16
|
|
|
{ |
17
|
1 |
|
public function testConstructWithSelf(): void |
18
|
|
|
{ |
19
|
1 |
|
$workerMock = $this->createMock(WorkerInterface::class); |
20
|
1 |
|
$workerMap = new WorkerMap(['mock' => $workerMock]); |
21
|
1 |
|
$newMap = new WorkerMap($workerMap); |
22
|
1 |
|
$this->assertCount(1, $newMap); |
23
|
1 |
|
$this->assertNotSame($workerMap, $newMap); |
24
|
1 |
|
$this->assertEquals($workerMap, $newMap); |
25
|
1 |
|
} |
26
|
|
|
|
27
|
1 |
|
public function testPush(): void |
28
|
|
|
{ |
29
|
1 |
|
$emptyMap = new WorkerMap; |
30
|
|
|
/** @var WorkerInterface $workerMock */ |
31
|
1 |
|
$workerMock = $this->createMock(WorkerInterface::class); |
32
|
1 |
|
$workerMap = $emptyMap->with('mock', $workerMock); |
33
|
1 |
|
$this->assertCount(1, $workerMap); |
34
|
1 |
|
$this->assertEquals($workerMock, $workerMap->get('mock')); |
35
|
1 |
|
$this->assertTrue($emptyMap->isEmpty()); |
36
|
1 |
|
} |
37
|
|
|
} |
38
|
|
|
|