WindowsAzureTest.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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_Document
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 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_Document_Adapter_WindowsAzureTest::main() if this source file is executed directly.
  22. if (!defined("PHPUnit_MAIN_METHOD")) {
  23. define("PHPUnit_MAIN_METHOD", "Zend_Cloud_DocumentService_Adapter_WindowsAzureTest::main");
  24. }
  25. require_once dirname(__FILE__) . '/../../../../TestHelper.php';
  26. /**
  27. * @see Zend_Cloud_DocumentServiceTestCase
  28. */
  29. require_once 'Zend/Cloud/DocumentService/TestCase.php';
  30. /**
  31. * @see Zend_Cloud_DocumentService_Adapter_WindowsAzure
  32. */
  33. require_once 'Zend/Cloud/DocumentService/Adapter/WindowsAzure.php';
  34. /**
  35. * @see Zend_Cloud_DocumentService_Factory
  36. */
  37. require_once 'Zend/Cloud/DocumentService/Factory.php';
  38. /** @see Zend_Config */
  39. require_once 'Zend/Config.php';
  40. /**
  41. * @category Zend
  42. * @package Zend_Cloud
  43. * @subpackage UnitTests
  44. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  45. * @license http://framework.zend.com/license/new-bsd New BSD License
  46. */
  47. class Zend_Cloud_DocumentService_Adapter_WindowsAzureTest
  48. extends Zend_Cloud_DocumentService_TestCase
  49. {
  50. /**
  51. * Period to wait for propagation in seconds
  52. * Should be set by adapter
  53. *
  54. * @var int
  55. */
  56. protected $_waitPeriod = 10;
  57. protected $_clientType = 'Zend_Service_WindowsAzure_Storage_Table';
  58. /**
  59. * Runs the test methods of this class.
  60. *
  61. * @access public
  62. * @static
  63. */
  64. public static function main()
  65. {
  66. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  67. $result = PHPUnit_TextUI_TestRunner::run($suite);
  68. }
  69. public function testQueryStructOrder()
  70. {
  71. try {
  72. parent::testQueryStructOrder();
  73. } catch(Zend_Cloud_OperationNotAvailableException $e) {
  74. $this->_commonDocument->deleteCollection($this->_collectionName("testStructQuery4"));
  75. $this->markTestSkipped('Azure query sorting not implemented yet');
  76. }
  77. }
  78. static function getConfigArray()
  79. {
  80. return array(
  81. Zend_Cloud_DocumentService_Factory::DOCUMENT_ADAPTER_KEY => 'Zend_Cloud_DocumentService_Adapter_WindowsAzure',
  82. Zend_Cloud_DocumentService_Adapter_WindowsAzure::ACCOUNT_NAME => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME'),
  83. Zend_Cloud_DocumentService_Adapter_WindowsAzure::ACCOUNT_KEY => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY'),
  84. Zend_Cloud_DocumentService_Adapter_WindowsAzure::HOST => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_TABLE_HOST'),
  85. Zend_Cloud_DocumentService_Adapter_WindowsAzure::PROXY_HOST => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_HOST'),
  86. Zend_Cloud_DocumentService_Adapter_WindowsAzure::PROXY_PORT => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_PORT'),
  87. Zend_Cloud_DocumentService_Adapter_WindowsAzure::PROXY_CREDENTIALS => constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_STORAGE_PROXY_CREDENTIALS'),
  88. );
  89. }
  90. protected function _getConfig()
  91. {
  92. if (!defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ENABLED') ||
  93. !constant('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ENABLED') ||
  94. !defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTNAME') ||
  95. !defined('TESTS_ZEND_SERVICE_WINDOWSAZURE_ONLINE_ACCOUNTKEY')) {
  96. $this->markTestSkipped("Windows Azure access not configured, skipping test");
  97. }
  98. $config = new Zend_Config(self::getConfigArray());
  99. return $config;
  100. }
  101. protected function _getDocumentData()
  102. {
  103. return array(
  104. array(
  105. parent::ID_FIELD => array("Amazon", "0385333498"),
  106. "name" => "The Sirens of Titan",
  107. "author" => "Kurt Vonnegut",
  108. "year" => 1959,
  109. "pages" => 336,
  110. "keyword" => "Book"
  111. ),
  112. array(
  113. parent::ID_FIELD => array("Amazon", "0802131786"),
  114. "name" => "Tropic of Cancer",
  115. "author" => "Henry Miller",
  116. "year" => 1934,
  117. "pages" => 318,
  118. "keyword" => "Book"
  119. ),
  120. array(
  121. parent::ID_FIELD => array("Amazon", "B000T9886K"),
  122. "name" => "In Between",
  123. "author" => "Paul Van Dyk",
  124. "year" => 2007,
  125. "keyword" => "CD"
  126. ),
  127. array(
  128. parent::ID_FIELD => array("Amazon", "1579124585"),
  129. "name" => "The Right Stuff",
  130. "author" => "Tom Wolfe",
  131. "year" => 1979,
  132. "pages" => 304,
  133. "keyword" => "Book"
  134. ),
  135. );
  136. }
  137. protected function _queryString($domain, $s1, $s2)
  138. {
  139. $k1 = $s1[1];
  140. $k2 = $s2[1];
  141. return "RowKey eq '$k1' or RowKey eq '$k2'";
  142. }
  143. }
  144. if (PHPUnit_MAIN_METHOD == 'Zend_Cloud_DocumentService_Adapter_WindowsAzureTest::main') {
  145. Zend_Cloud_DocumentService_Adapter_WindowsAzureTest::main();
  146. }