ForwardCompatibleTestCase::createMock()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.9765

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
ccs 3
cts 8
cp 0.375
crap 2.9765
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace egabor\Composer\ReleasePlugin\Test;
4
5
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
abstract class ForwardCompatibleTestCase extends TestCase
8
{
9
    private $expectedException;
10
    private $expectedExceptionMessage = '';
11
    private $expectedExceptionCode;
12
13 69
    public function expectException($exception)
14
    {
15 69
        if (is_callable('parent::expectException')) {
16 69
            parent::expectException($exception);
17
        } else {
18
            $this->expectedException = $exception;
19
            $this->setExpectedException($exception, $this->expectedExceptionMessage, $this->expectedExceptionCode);
20
        }
21 69
    }
22
23 52
    public function expectExceptionMessage($message)
24
    {
25 52
        if (is_callable('parent::expectExceptionMessage')) {
26 52
            parent::expectExceptionMessage($message);
27
        } else {
28
            $this->expectedExceptionMessage = $message;
29
            $this->setExpectedException($this->expectedException, $message, $this->expectedExceptionCode);
30
        }
31 52
    }
32
33
    public function expectExceptionCode($code)
34
    {
35
        if (is_callable('parent::expectExceptionCode')) {
36
            parent::expectExceptionCode($code);
37
        } else {
38
            $this->expectedExceptionCode = $code;
39
            $this->setExpectedException($this->expectedException, $this->expectedExceptionMessage, $code);
40
        }
41
    }
42
43
    public function expectExceptionObject(\Exception $exception)
44
    {
45
        if (is_callable('parent::expectExceptionObject')) {
46
            parent::expectExceptionObject($exception);
47
        } else {
48
            $this->expectException(\get_class($exception));
49
            $this->expectExceptionMessage($exception->getMessage());
50
            $this->expectExceptionCode($exception->getCode());
51
        }
52
    }
53
54 1
    protected function createMock($originalClassName)
55
    {
56 1
        if (is_callable('parent::createMock')) {
57 1
            return parent::createMock($originalClassName);
58
        }
59
60
        return $this->getMockBuilder($originalClassName)
61
            ->disableOriginalConstructor()
62
            ->disableOriginalClone()
63
            ->disableArgumentCloning()
64
            ->getMock();
65
    }
66
}
67