SyncOptionsFactoryTest::testInvoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 6
c 2
b 0
f 0
dl 0
loc 21
rs 10
cc 2
nc 2
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TogglJiraTest\Options;
5
6
use TogglJira\Options\SyncOptions;
7
use TogglJira\Options\SyncOptionsFactory;
8
use TogglJiraTest\BaseContainerTest;
9
10
class SyncOptionsFactoryTest extends BaseContainerTest
11
{
12
    /**
13
     * @return void
14
     * @throws \Interop\Container\Exception\ContainerException
15
     */
16
    public function testInvoke(): void
17
    {
18
        if (file_exists(__DIR__ . '/../../../../config.json')) {
19
            rename(__DIR__ . '/../../../../config.json', __DIR__ . '/../../../../config.json.bak');
20
        }
21
22
        file_put_contents(__DIR__ . '/../../../../config.json', '{
23
            "lastSync": {
24
                "date": "2018-04-03T10:10:55+02:00",
25
                "timezone": "Europe/Amsterdam"
26
            },
27
            "jiraUrl": "https://jira.atlassian.net",
28
            "jiraUsername": "foo",
29
            "jiraPassword": "bar",
30
            "togglApiKey": "baz"
31
        }');
32
33
        $factory = new SyncOptionsFactory();
34
        $instance  = $factory->__invoke($this->getContainer(), SyncOptions::class);
35
36
        $this->assertInstanceOf(SyncOptions::class, $instance);
37
    }
38
39
    public function tearDown()/* The :void return type declaration that should be here would cause a BC issue */
40
    {
41
        parent::tearDown();
42
43
        \unlink(__DIR__ . '/../../../../config.json');
44
45
        if (\file_exists(__DIR__ . '/../../../../config.json.bak')) {
46
            \rename(__DIR__ . '/../../../../config.json.bak', __DIR__ . '/../../../../config.json');
47
        }
48
    }
49
}
50