These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* vim: set expandtab sw=4 ts=4 sts=4: */ |
||
3 | /** |
||
4 | * Base class for phpMyAdmin tests |
||
5 | * |
||
6 | * @package PhpMyAdmin-test |
||
7 | */ |
||
8 | |||
9 | class PMATestCase extends PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | protected $restoreInstance = null; |
||
12 | protected $attrInstance = null; |
||
13 | |||
14 | /** |
||
15 | * This method is called before the first test of this test class is run. |
||
16 | */ |
||
17 | public static function setUpBeforeClass() |
||
18 | { |
||
19 | require 'libraries/config.default.php'; |
||
20 | $GLOBALS['cfg'] = $cfg; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Creates mock of Response object for header testing |
||
25 | * |
||
26 | * @param mixed $param parameter for header method |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function mockResponse($param) |
||
0 ignored issues
–
show
|
|||
31 | { |
||
32 | $this->restoreInstance = PMA\libraries\Response::getInstance(); |
||
33 | |||
34 | $mockResponse = $this->getMockBuilder('PMA\libraries\Response') |
||
35 | ->disableOriginalConstructor() |
||
36 | ->setMethods(array('header', 'headersSent', 'disable', 'isAjax')) |
||
37 | ->getMock(); |
||
38 | |||
39 | $mockResponse->expects($this->any()) |
||
40 | ->method('headersSent') |
||
41 | ->with() |
||
42 | ->will($this->returnValue(false)); |
||
43 | |||
44 | $param = func_get_args(); |
||
45 | |||
46 | if (is_array($param[0])) { |
||
47 | $header_method = $mockResponse->expects($this->exactly(count($param))) |
||
48 | ->method('header'); |
||
49 | |||
50 | call_user_func_array(array($header_method, 'withConsecutive'), $param); |
||
51 | } else { |
||
52 | $mockResponse->expects($this->once()) |
||
53 | ->method('header') |
||
54 | ->with($param[0]); |
||
55 | } |
||
56 | |||
57 | $this->attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance'); |
||
58 | $this->attrInstance->setAccessible(true); |
||
59 | $this->attrInstance->setValue($mockResponse); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | *Tear down function for mockResponse method |
||
64 | * |
||
65 | *@return void |
||
66 | */ |
||
67 | protected function tearDown() |
||
68 | { |
||
69 | if (! is_null($this->attrInstance) && ! is_null($this->restoreInstance)) { |
||
70 | $this->attrInstance->setValue($this->restoreInstance); |
||
71 | $this->restoreInstance = null; |
||
72 | $this->attrInstance = null; |
||
73 | } |
||
74 | } |
||
75 | } |
||
76 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.