forked from etsy/411
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCase.php
More file actions
39 lines (30 loc) · 998 Bytes
/
Copy pathTestCase.php
File metadata and controls
39 lines (30 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class TestCase extends PHPUnit_Framework_TestCase {
protected $requestTime;
protected $config;
public function setUp() {
$GLOBALS['TESTING'] = true;
$this->requestTime = $_SERVER['REQUEST_TIME'];
$this->config = FOO\Config::getData();
FOO\Config::init([]);
$_SERVER['REQUEST_TIME'] = 1460000000;
TestHelper::setupDB();
}
public function tearDown() {
TestHelper::teardownDB();
$_SERVER['REQUEST_TIME'] = $this->requestTime;
FOO\Config::init($this->config);
$this->config = null;
$this->requestTime = null;
$GLOBALS['TESTING'] = false;
}
public function getMockObject($type, $arr) {
$obj = $this->getMock($type, array('offsetGet'));
$obj->expects($this->any())
->method('offsetGet')
->will($this->returnCallback(function($key) use ($arr) {
return $arr[$key];
}));
return $obj;
}
}