PageRenderTime 20ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/ZendTest/Cache/Storage/Adapter/AbstractDbaTest.php

http://github.com/zendframework/zf2
PHP | 64 lines | 43 code | 11 blank | 10 comment | 3 complexity | 83e52a12c33b28986ec35ffb30aad794 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace ZendTest\Cache\Storage\Adapter;
  10. use Zend\Cache;
  11. /**
  12. * @group Zend_Cache
  13. */
  14. abstract class AbstractDbaTest extends CommonAdapterTest
  15. {
  16. protected $handler;
  17. protected $temporaryDbaFile;
  18. public function setUp()
  19. {
  20. if (!extension_loaded('dba')) {
  21. try {
  22. new Cache\Storage\Adapter\Dba();
  23. $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException");
  24. } catch (Cache\Exception\ExtensionNotLoadedException $e) {
  25. $this->markTestSkipped("Missing ext/dba");
  26. }
  27. }
  28. if (!in_array($this->handler, dba_handlers())) {
  29. try {
  30. new Cache\Storage\Adapter\DbaOptions(array('handler' => $this->handler));
  31. $this->fail("Expected exception Zend\Cache\Exception\ExtensionNotLoadedException");
  32. } catch (Cache\Exception\ExtensionNotLoadedException $e) {
  33. $this->markTestSkipped("Missing ext/dba handler '{$this->handler}'");
  34. }
  35. }
  36. $this->temporaryDbaFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('zfcache_dba_') . '.' . $this->handler;
  37. $this->_options = new Cache\Storage\Adapter\DbaOptions(array(
  38. 'pathname' => $this->temporaryDbaFile,
  39. 'handler' => $this->handler,
  40. ));
  41. $this->_storage = new Cache\Storage\Adapter\Dba();
  42. $this->_storage->setOptions($this->_options);
  43. parent::setUp();
  44. }
  45. public function tearDown()
  46. {
  47. $this->_storage = null;
  48. if (file_exists($this->temporaryDbaFile)) {
  49. unlink($this->temporaryDbaFile);
  50. }
  51. parent::tearDown();
  52. }
  53. }