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

TransportMapTest::testPush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 1
b 0
f 1
ccs 7
cts 7
cp 1
cc 1
nc 1
nop 0
crap 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