1 | <?php |
||
13 | abstract class CouchDBFunctionalTestCase extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | private $httpClient = null; |
||
16 | |||
17 | protected $logger; |
||
18 | |||
19 | /** |
||
20 | * @return \Doctrine\CouchDB\HTTP\Client |
||
21 | */ |
||
22 | public function getHttpClient() |
||
|
|||
23 | { |
||
24 | if ($this->httpClient === null) { |
||
25 | if (isset($GLOBALS['DOCTRINE_COUCHDB_CLIENT'])) { |
||
26 | $this->httpClient = new $GLOBALS['DOCTRINE_COUCHDB_CLIENT']; |
||
27 | } else { |
||
28 | $this->httpClient = new SocketClient(); |
||
29 | } |
||
30 | |||
31 | $this->logger = new \Doctrine\CouchDB\HTTP\LoggingClient($this->httpClient); |
||
32 | } |
||
33 | |||
34 | return $this->logger; |
||
35 | } |
||
36 | |||
37 | public function getTestDatabase() |
||
41 | |||
42 | public function createCouchDBClient() |
||
46 | |||
47 | public function createDocumentManager() |
||
69 | |||
70 | protected function isVersion2(CouchDBClient $couchDBClient) |
||
74 | |||
75 | public function createConfiguration($metaDriver) |
||
86 | } |
||
87 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: