RackspaceTest.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend\Cloud\StorageService\Adapter
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. // Call Zend_Cloud_StorageService_Adapter_RackspaceTest::main() if this source file is executed directly.
  22. if (!defined("PHPUnit_MAIN_METHOD")) {
  23. define("PHPUnit_MAIN_METHOD", "Zend_Cloud_StorageService_Adapter_RackspaceTest::main");
  24. }
  25. require_once 'Zend/Service/Rackspace/Files.php';
  26. require_once 'Zend/Config.php';
  27. require_once 'Zend/Cloud/StorageService/TestCase.php';
  28. /**
  29. * @category Zend
  30. * @package Zend\Cloud\StorageService\Adapter
  31. * @subpackage UnitTests
  32. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Cloud_StorageService_Adapter_RackspaceTest extends Zend_Cloud_StorageService_TestCase
  36. {
  37. protected $_clientType = 'Zend_Service_Rackspace_Files';
  38. public function testFetchItemStream()
  39. {
  40. // The Rackspace client library doesn't support streams
  41. $this->markTestSkipped('The Rackspace client library doesn\'t support streams.');
  42. }
  43. public function testStoreItemStream()
  44. {
  45. // The Rackspace client library doesn't support streams
  46. $this->markTestSkipped('The Rackspace client library doesn\'t support streams.');
  47. }
  48. /**
  49. * Sets up this test case
  50. *
  51. * @return void
  52. */
  53. public function setUp()
  54. {
  55. if (!constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')) {
  56. $this->markTestSkipped('Rackspace online tests are not enabled');
  57. }
  58. parent::setUp();
  59. $this->_waitPeriod = 5;
  60. // Create the container here
  61. $rackspace= new Zend_Service_Rackspace_Files(
  62. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::USER),
  63. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::API_KEY)
  64. );
  65. $rackspace->createContainer(
  66. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER)
  67. );
  68. }
  69. /**
  70. * Tears down this test case
  71. *
  72. * @return void
  73. */
  74. public function tearDown()
  75. {
  76. if (!$this->_config) {
  77. return;
  78. }
  79. // Delete the container here
  80. $rackspace = new Zend_Service_Rackspace_Files(
  81. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::USER),
  82. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::API_KEY)
  83. );
  84. $files = $rackspace->getObjects(
  85. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER)
  86. );
  87. if ($files==!false) {
  88. foreach ($files as $file) {
  89. $rackspace->deleteObject(
  90. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER),
  91. $file->getName()
  92. );
  93. }
  94. }
  95. $rackspace->deleteContainer(
  96. $this->_config->get(Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER)
  97. );
  98. parent::tearDown();
  99. }
  100. protected function _getConfig()
  101. {
  102. if (!defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_ENABLED')
  103. || !constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER')
  104. || !defined('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY')
  105. || !defined('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME')
  106. ) {
  107. $this->markTestSkipped("Rackspace access not configured, skipping test");
  108. }
  109. $config = new Zend_Config(array(
  110. Zend_Cloud_StorageService_Factory::STORAGE_ADAPTER_KEY => 'Zend_Cloud_StorageService_Adapter_Rackspace',
  111. Zend_Cloud_StorageService_Adapter_Rackspace::USER => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_USER'),
  112. Zend_Cloud_StorageService_Adapter_Rackspace::API_KEY => constant('TESTS_ZEND_SERVICE_RACKSPACE_ONLINE_KEY'),
  113. Zend_Cloud_StorageService_Adapter_Rackspace::REMOTE_CONTAINER => constant('TESTS_ZEND_SERVICE_RACKSPACE_CONTAINER_NAME')
  114. ));
  115. return $config;
  116. }
  117. }
  118. if (PHPUnit_MAIN_METHOD == 'Zend_Cloud_StorageService_Adapter_RackspaceTest::main') {
  119. Zend_Cloud_StorageService_Adapter_RackspaceTest::main();
  120. }