WindowsAzureTest.php 5.4 KB

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