HTTPTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 1
b 0
f 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testNonExistingDirectoryPath() 0 8 1
A testDirectoryPath() 0 10 2
A __construct() 0 4 1
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
}