Translated using Weblate (Bengali)
[phpmyadmin.git] / test / PMATestCase.php
blob68b26441088f07f1db36b6a17e12c14441ce7fc4
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Base class for phpMyAdmin tests
6 * @package PhpMyAdmin-test
7 */
9 class PMATestCase extends PHPUnit_Framework_TestCase
11 protected $restoreInstance = null;
12 protected $attrInstance = null;
14 /**
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;
23 /**
24 * Creates mock of Response object for header testing
26 * @param mixed $param parameter for header method
28 * @return void
30 public function mockResponse()
32 $this->restoreInstance = PMA\libraries\Response::getInstance();
34 $mockResponse = $this->getMockBuilder('PMA\libraries\Response')
35 ->disableOriginalConstructor()
36 ->setMethods(array(
37 'header', 'headersSent', 'disable', 'isAjax',
38 'setRequestStatus', 'addJSON', 'addHTML',
39 'getFooter', 'getHeader',
41 ->getMock();
43 $mockResponse->expects($this->any())
44 ->method('headersSent')
45 ->with()
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) {
53 $param = $param[0];
55 $header_method = $mockResponse->expects($this->exactly(count($param)))
56 ->method('header');
58 call_user_func_array(array($header_method, 'withConsecutive'), $param);
59 } else {
60 $mockResponse->expects($this->once())
61 ->method('header')
62 ->with($param[0]);
66 $this->attrInstance = new ReflectionProperty('PMA\libraries\Response', '_instance');
67 $this->attrInstance->setAccessible(true);
68 $this->attrInstance->setValue($mockResponse);
70 return $mockResponse;
73 /**
74 *Tear down function for mockResponse method
76 *@return void
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;