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

ChannelMapTest   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 testConstructWithDuplicateKey() 0 6 1
A testPush() 0 9 1
A testConstructWithSelf() 0 8 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\ChannelInterface;
12
use Daikon\MessageBus\Channel\ChannelMap;
13
use InvalidArgumentException;
14
use PHPUnit\Framework\TestCase;
15
16
final class ChannelMapTest extends TestCase
17
{
18 1
    public function testConstructWithSelf(): void
19
    {
20 1
        $channelMock = $this->createMock(ChannelInterface::class);
21 1
        $channelMock->expects($this->exactly(2))->method('getKey')->willReturn('mock');
22 1
        $channelMap = new ChannelMap([$channelMock]);
23 1
        $newMap = new ChannelMap($channelMap);
24 1
        $this->assertCount(1, $newMap);
25 1
        $this->assertFalse($channelMap === $newMap);
26 1
    }
27
28 1
    public function testConstructWithDuplicateKey(): void
29
    {
30 1
        $this->expectException(InvalidArgumentException::class);
31 1
        $channelMock = $this->createMock(ChannelInterface::class);
32 1
        $channelMock->expects($this->exactly(2))->method('getKey')->willReturn('mock');
33 1
        new ChannelMap([$channelMock, $channelMock]);
34
    }
35
36 1
    public function testPush(): void
37
    {
38 1
        $emptyMap = new ChannelMap;
39
        /** @var ChannelInterface $channelMock */
40 1
        $channelMock = $this->createMock(ChannelInterface::class);
41 1
        $channelMap = $emptyMap->with('mock', $channelMock);
42 1
        $this->assertCount(1, $channelMap);
43 1
        $this->assertEquals($channelMock, $channelMap->get('mock'));
44 1
        $this->assertTrue($emptyMap->isEmpty());
45 1
    }
46
}
47