Test Failed
Pull Request — master (#6)
by Timon
07:57
created

SyncOptionsFactoryTest::testInvokeThrowsException()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
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.phpunit.json')) {
19
            rename(__DIR__ . '/../../../../config.phpunit.json', __DIR__ . '/../../../../config.phpunit.json.bak');
20
        }
21
22
        file_put_contents(__DIR__ . '/../../../../config.phpunit.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.phpunit.json');
44
45
        if (\file_exists(__DIR__ . '/../../../../config.phpunit.json.bak')) {
46
            \rename(__DIR__ . '/../../../../config.phpunit.json.bak', __DIR__ . '/../../../../config.phpunit.json');
47
        }
48
    }
49
}
50