WorkLogHydratorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 25
c 1
b 0
f 0
dl 0
loc 49
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExtract() 0 20 1
A testHydrate() 0 17 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TogglJiraTest\Hydrator;
5
6
use PHPUnit\Framework\TestCase;
7
use TogglJira\Entity\WorkLogEntry;
8
use TogglJira\Hydrator\WorkLogHydrator;
9
10
class WorkLogHydratorTest extends TestCase
11
{
12
    /**
13
     * @return void
14
     * @throws \Exception
15
     */
16
    public function testHydrate(): void
17
    {
18
        $hydrator = new WorkLogHydrator();
19
20
        $data = [
21
            'issueID' => 'SLR-76',
22
            'timeSpent' => 666,
23
            'comment' => 'Soldier 76, reporting for duty',
24
            'spentOn' => '2017-04-15T23:35:00+02:00'
25
        ];
26
27
        $object = $hydrator->hydrate($data, new WorkLogEntry());
28
29
        $this->assertEquals($data['issueID'], $object->getIssueID());
30
        $this->assertEquals($data['timeSpent'], $object->getTimeSpent());
31
        $this->assertEquals($data['comment'], $object->getComment());
32
        $this->assertEquals($data['spentOn'], $object->getSpentOn()->format(DATE_ATOM));
33
    }
34
35
    /**
36
     * @return void
37
     * @throws \Exception
38
     */
39
    public function testExtract(): void
40
    {
41
        $hydrator = new WorkLogHydrator();
42
43
        $data = [
44
            'issueID' => 'DVA-42',
45
            'timeSpent' => 9001,
46
            'comment' => 'Nerf this!',
47
            'spentOn' => new \DateTimeImmutable('2017-04-15T23:50:00+02:0')
48
        ];
49
50
        $object = new WorkLogEntry();
51
        $object->setIssueID($data['issueID']);
52
        $object->setTimeSpent($data['timeSpent']);
53
        $object->setComment($data['comment']);
54
        $object->setSpentOn($data['spentOn']);
55
56
        $expected = $hydrator->extract($object);
57
58
        $this->assertEquals($data, $expected);
59
    }
60
}
61