Skip to content

Commit e99a90b

Browse files
committed
Do not use globals
1 parent 37411d8 commit e99a90b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/BaseTestCase.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323
abstract class BaseTestCase extends \PHPUnit_Framework_TestCase
2424
{
2525
/**
26-
* Get a real HTTP client. If $_SERVER['RESPONSE_CACHE'] is set to a path it will use cached responses.
26+
* @return string|null the directory where cached responses are stored
27+
*/
28+
abstract protected function getCacheDir();
29+
30+
/**
31+
* Get a real HTTP client. If a cache dir is set to a path it will use cached responses.
2732
*
2833
* @return HttpClient
2934
*/
3035
protected function getHttpClient($apiKey = null)
3136
{
32-
if (isset($_SERVER['RESPONSE_CACHE']) && false !== $_SERVER['RESPONSE_CACHE']) {
33-
return new CachedResponseClient(new HttplugClient(), $_SERVER['RESPONSE_CACHE'], $apiKey);
37+
if (null !== $cacheDir = $this->getCacheDir()) {
38+
return new CachedResponseClient(new HttplugClient(), $cacheDir, $apiKey);
3439
} else {
3540
return new HttplugClient();
3641
}

0 commit comments

Comments
 (0)