2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Base class for phpMyAdmin tests
6 * @package PhpMyAdmin-test
9 class PMATestCase
extends PHPUnit_Framework_TestCase
11 protected $restoreInstance = null;
12 protected $attrInstance = null;
15 * This method is called before the first test of this test class is run.
17 public static function setUpBeforeClass()
19 require 'libraries/config.default.php';
20 $GLOBALS['cfg'] = $cfg;
24 * Creates mock of Response object for header testing
26 * @param mixed $param parameter for header method
30 public function mockResponse()
32 $this->restoreInstance
= PMA\libraries\Response
::getInstance();
34 $mockResponse = $this->getMockBuilder('PMA\libraries\Response')
35 ->disableOriginalConstructor()
37 'header', 'headersSent', 'disable', 'isAjax',
38 'setRequestStatus', 'addJSON', 'addHTML',
39 'getFooter', 'getHeader',
43 $mockResponse->expects($this->any())
44 ->method('headersSent')
46 ->will($this->returnValue(false));
48 $param = func_get_args();
50 if (count($param) > 0) {
51 if (is_array($param[0])) {
52 if (is_array($param[0][0]) && count($param) == 1) {
55 $header_method = $mockResponse->expects($this->exactly(count($param)))
58 call_user_func_array(array($header_method, 'withConsecutive'), $param);
60 $mockResponse->expects($this->once())
66 $this->attrInstance
= new ReflectionProperty('PMA\libraries\Response', '_instance');
67 $this->attrInstance
->setAccessible(true);
68 $this->attrInstance
->setValue($mockResponse);
74 *Tear down function for mockResponse method
78 protected function tearDown()
80 if (! is_null($this->attrInstance
) && ! is_null($this->restoreInstance
)) {
81 $this->attrInstance
->setValue($this->restoreInstance
);
82 $this->restoreInstance
= null;
83 $this->attrInstance
= null;