HTTPTest::testDirectoryPath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
namespace LE_ACME2Tests\Authorizer;
3
4
use LE_ACME2Tests\AbstractLeAcme2TestCase;
5
use LE_ACME2Tests\TestHelper;
6
7
/**
8
 * @covers \LE_ACME2\Authorizer\HTTP
9
 */
10
class HTTPTest extends AbstractLeAcme2TestCase {
11
12
    private $_directoryPath;
13
14
    public function __construct(string $name) {
15
        parent::__construct($name);
16
17
        $this->_directoryPath = TestHelper::getInstance()->getTempPath() . 'acme-challenges/';
0 ignored issues
show
Bug introduced by
It seems like getTempPath() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        $this->_directoryPath = TestHelper::getInstance()->/** @scrutinizer ignore-call */ getTempPath() . 'acme-challenges/';
Loading history...
18
    }
19
20
    public function testNonExistingDirectoryPath() {
21
22
        $this->assertTrue(\LE_ACME2\Authorizer\HTTP::getDirectoryPath() === null);
23
24
        $this->catchExpectedException(
25
            \RuntimeException::class,
26
            function() {
27
                \LE_ACME2\Authorizer\HTTP::setDirectoryPath(TestHelper::getInstance()->getNonExistingPath());
0 ignored issues
show
Bug introduced by
It seems like getNonExistingPath() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
                \LE_ACME2\Authorizer\HTTP::setDirectoryPath(TestHelper::getInstance()->/** @scrutinizer ignore-call */ getNonExistingPath());
Loading history...
28
            }
29
        );
30
    }
31
32
    public function testDirectoryPath() {
33
34
        if(!file_exists($this->_directoryPath)) {
35
            mkdir($this->_directoryPath);
36
        }
37
38
        \LE_ACME2\Authorizer\HTTP::setDirectoryPath($this->_directoryPath);
39
40
        $this->assertTrue(
41
            \LE_ACME2\Authorizer\HTTP::getDirectoryPath() === $this->_directoryPath
42
        );
43
    }
44
}