Completed
Push — master ( 1d87d0...2a331f )
by Al3x
04:12
created

ContactsStrategyTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 61
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testCreate() 0 4 1
A testExtractEmpty() 0 8 1
A testExtract() 0 10 1
A testHydrateEmpty() 0 9 1
A testHydrate() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace InvoiceNinjaModuleTest\Strategy;
5
6
use InvoiceNinjaModule\Model\Interfaces\ContactInterface;
7
use InvoiceNinjaModule\Strategy\ContactsStrategy;
8
use PHPUnit\Framework\TestCase;
9
use Zend\Hydrator\HydratorInterface;
10
11
class ContactsStrategyTest extends TestCase
12
{
13
    private $hydratorMock;
14
    /** @var  ContactsStrategy */
15
    private $strategy;
16
17
18
    protected function setUp() :void
19
    {
20
        parent::setUp();
21
        $this->hydratorMock = $this->createMock(HydratorInterface::class);
22
        $this->strategy = new ContactsStrategy($this->hydratorMock);
23
    }
24
25
    public function testCreate() :void
26
    {
27
        self::assertInstanceOf(ContactsStrategy::class, $this->strategy);
28
    }
29
30
    public function testExtractEmpty() :void
31
    {
32
        $testValue = [];
33
34
        $result = $this->strategy->extract($testValue);
35
        self::assertEmpty($result);
36
        self::assertInternalType('array', $result);
37
    }
38
39
    public function testExtract() :void
40
    {
41
        $testValue = [
42
            $this->createMock(ContactInterface::class)
43
        ];
44
45
        $result = $this->strategy->extract($testValue);
46
        self::assertNotEmpty($result);
47
        self::assertInternalType('array', $result);
48
    }
49
50
    public function testHydrateEmpty() :void
51
    {
52
        $testValue = [
53
        ];
54
55
        $result = $this->strategy->hydrate($testValue);
56
        self::assertEmpty($result);
57
        self::assertInternalType('array', $result);
58
    }
59
60
    public function testHydrate() :void
61
    {
62
        $testValue = [
63
            [ 'id' => 1]
64
        ];
65
66
        $result = $this->strategy->hydrate($testValue);
67
        self::assertNotEmpty($result);
68
        self::assertInternalType('array', $result);
69
        self::assertInstanceOf(ContactInterface::class, $result[0]);
70
    }
71
}
72