1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Netgen\Bundle\SiteAccessRoutesBundle\Tests; |
4
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This class is a compatibility layer for using |
9
|
|
|
* PHPUnit 4.8 on PHP 5.5 and PHPUnit 5.5 on PHP >= 5.6. |
10
|
|
|
*/ |
11
|
|
|
class TestCase extends PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Returns a test double for the specified class. |
15
|
|
|
* |
16
|
|
|
* @param string $originalClassName |
17
|
|
|
* |
18
|
|
|
* @throws \PHPUnit_Framework_Exception |
19
|
|
|
* |
20
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
21
|
|
|
*/ |
22
|
|
|
protected function createMock($originalClassName) |
23
|
|
|
{ |
24
|
|
|
if (method_exists(PHPUnit_Framework_TestCase::class, 'createMock')) { |
25
|
|
|
return parent::createMock($originalClassName); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
return $this |
29
|
|
|
->getMockBuilder($originalClassName) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->disableOriginalClone() |
32
|
|
|
->disableArgumentCloning() |
33
|
|
|
->getMock(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Returns a partial test double for the specified class. |
38
|
|
|
* |
39
|
|
|
* @param string $originalClassName |
40
|
|
|
* @param array $methods |
41
|
|
|
* |
42
|
|
|
* @throws \PHPUnit_Framework_Exception |
43
|
|
|
* |
44
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject |
45
|
|
|
*/ |
46
|
|
|
protected function createPartialMock($originalClassName, array $methods) |
47
|
|
|
{ |
48
|
|
|
if (method_exists(PHPUnit_Framework_TestCase::class, 'createPartialMock')) { |
49
|
|
|
return parent::createPartialMock($originalClassName, $methods); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return $this |
53
|
|
|
->getMockBuilder($originalClassName) |
54
|
|
|
->disableOriginalConstructor() |
55
|
|
|
->disableOriginalClone() |
56
|
|
|
->disableArgumentCloning() |
57
|
|
|
->setMethods($methods) |
58
|
|
|
->getMock(); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|