TestCase::expectException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/*
3
 * Ensures compatibility with PHPUnit < 6.x
4
 */
5
namespace PHPUnit\Framework\Constraint {
6
    if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
7
        abstract class Constraint extends \PHPUnit_Framework_Constraint
8
        {
9
        }
10
    }
11
}
12
namespace PHPUnit\Framework {
13
    if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
14
        abstract class TestCase extends \PHPUnit_Framework_TestCase
15
        {
16
            /**
17
             * @param string $exception
18
             */
19
            public function expectException($exception)
20
            {
21
                $this->setExpectedException($exception);
22
            }
23
            /**
24
             * @param string $message
25
             */
26
            public function expectExceptionMessage($message)
27
            {
28
                $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
29
                if (in_array('expectExceptionMessage', $parentClassMethods)) {
30
                    parent::expectExceptionMessage($message);
31
                    return;
32
                }
33
                $this->setExpectedException($this->getExpectedException(), $message);
34
            }
35
            /**
36
             * @param string $messageRegExp
37
             */
38
            public function expectExceptionMessageRegExp($messageRegExp)
39
            {
40
                $parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
41
                if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) {
42
                    parent::expectExceptionMessageRegExp($messageRegExp);
43
                    return;
44
                }
45
                $this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp);
46
            }
47
        }
48
    }
49
}
50