Passed
Push — master ( 905821...42a403 )
by Mr
07:23
created

TransportMapTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 95.24%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 17
dl 0
loc 29
rs 10
c 1
b 0
f 1
ccs 20
cts 21
cp 0.9524

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructWithSelf() 0 8 1
A testPush() 0 9 1
A testConstructWithDuplicateKey() 0 6 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/message-bus 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\MessageBus;
10
11
use Daikon\MessageBus\Channel\Subscription\Transport\TransportInterface;
12
use Daikon\MessageBus\Channel\Subscription\Transport\TransportMap;
13
use InvalidArgumentException;
14
use PHPUnit\Framework\TestCase;
15
16
final class TransportMapTest extends TestCase
17
{
18 1
    public function testConstructWithSelf(): void
19
    {
20 1
        $transportMock = $this->createMock(TransportInterface::class);
21 1
        $transportMock->expects($this->exactly(2))->method('getKey')->willReturn('mock');
22 1
        $transportMap = new TransportMap([$transportMock]);
23 1
        $newMap = new TransportMap($transportMap);
24 1
        $this->assertCount(1, $newMap);
25 1
        $this->assertFalse($transportMap === $newMap);
26 1
    }
27
28 1
    public function testConstructWithDuplicateKey(): void
29
    {
30 1
        $this->expectException(InvalidArgumentException::class);
31 1
        $transportMock = $this->createMock(TransportInterface::class);
32 1
        $transportMock->expects($this->exactly(2))->method('getKey')->willReturn('mock');
33 1
        new TransportMap([$transportMock, $transportMock]);
34
    }
35
36 1
    public function testPush(): void
37
    {
38 1
        $emptyMap = new TransportMap;
39
        /** @var TransportInterface $transportMock */
40 1
        $transportMock = $this->createMock(TransportInterface::class);
41 1
        $transportMap = $emptyMap->with('mock', $transportMock);
42 1
        $this->assertCount(1, $transportMap);
43 1
        $this->assertEquals($transportMock, $transportMap->get('mock'));
44 1
        $this->assertTrue($emptyMap->isEmpty());
45 1
    }
46
}
47