Completed
Push — master ( d6f2f0...35cdc1 )
by Gábor
01:56
created

expectExceptionMessage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 7
rs 9.4285
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
    public function expectException($exception)
14
    {
15
        if (is_callable('parent::expectException')) {
16
            parent::expectException($exception);
17
        } else {
18
            $this->expectedException = $exception;
19
            $this->setExpectedException($exception, $this->expectedExceptionMessage, $this->expectedExceptionCode);
20
        }
21
    }
22
23
    public function expectExceptionMessage($message)
24
    {
25
        if (is_callable('parent::expectExceptionMessage')) {
26
            parent::expectExceptionMessage($message);
27
        } else {
28
            $this->expectedExceptionMessage = $message;
29
            $this->setExpectedException($this->expectedException, $message, $this->expectedExceptionCode);
30
        }
31
    }
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($e);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $e seems to be never defined.
Loading history...
47
        } else {
48
            $this->expectException(\get_class($exception));
49
            $this->expectExceptionMessage($exception->getMessage());
50
            $this->expectExceptionCode($exception->getCode());
51
        }
52
    }
53
54
    protected function createMock($originalClassName)
55
    {
56
        if (is_callable('parent::createMock')) {
57
            return parent::createMock($originalClassName);
58
        }
59
60
        return $this->getMockBuilder($originalClassName)
61
            ->disableOriginalConstructor()
62
            ->disableOriginalClone()
63
            ->disableArgumentCloning()
64
            ->getMock();
65
    }
66
}
67