PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/unit/WindowsAzure/Queue/Models/ListQueuesResultTest.php

https://bitbucket.org/skudatech/azure-sdk-for-php
PHP | 268 lines | 114 code | 43 blank | 111 comment | 0 complexity | 2d4e82291e5972a2909ee61eeda9c168 MD5 | raw file
  1. <?php
  2. /**
  3. * LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. *
  14. * PHP version 5
  15. *
  16. * @category Microsoft
  17. * @package Tests\Unit\WindowsAzure\Queue\Models
  18. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  19. * @copyright 2012 Microsoft Corporation
  20. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  21. * @link https://github.com/windowsazure/azure-sdk-for-php
  22. */
  23. namespace Tests\Unit\WindowsAzure\Queue\Models;
  24. use WindowsAzure\Queue\Models\ListQueuesResult;
  25. use Tests\Framework\TestResources;
  26. /**
  27. * Unit tests for class ListQueuesResult
  28. *
  29. * @category Microsoft
  30. * @package Tests\Unit\WindowsAzure\Queue\Models
  31. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  32. * @copyright 2012 Microsoft Corporation
  33. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  34. * @version Release: @package_version@
  35. * @link https://github.com/windowsazure/azure-sdk-for-php
  36. */
  37. class ListQueuesResultTest extends \PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * @covers WindowsAzure\Queue\Models\ListQueuesResult::create
  41. */
  42. public function testCreateWithEmpty()
  43. {
  44. // Setup
  45. $sample = TestResources::listQueuesEmpty();
  46. // Test
  47. $actual = ListQueuesResult::create($sample);
  48. // Assert
  49. $this->assertCount(0, $actual->getQueues());
  50. $this->assertTrue(empty($sample['NextMarker']));
  51. }
  52. /**
  53. * @covers WindowsAzure\Queue\Models\ListQueuesResult::create
  54. */
  55. public function testCreateWithOneEntry()
  56. {
  57. // Setup
  58. $sample = TestResources::listQueuesOneEntry();
  59. // Test
  60. $actual = ListQueuesResult::create($sample);
  61. // Assert
  62. $queues = $actual->getQueues();
  63. $this->assertCount(1, $queues);
  64. $this->assertEquals($sample['Queues']['Queue']['Name'], $queues[0]->getName());
  65. $this->assertEquals($sample['Queues']['Queue']['Url'], $queues[0]->getUrl());
  66. $this->assertEquals($sample['Marker'], $actual->getMarker());
  67. $this->assertEquals($sample['MaxResults'], $actual->getMaxResults());
  68. $this->assertEquals($sample['NextMarker'], $actual->getNextMarker());
  69. }
  70. /**
  71. * @covers WindowsAzure\Queue\Models\ListQueuesResult::create
  72. */
  73. public function testCreateWithMultipleEntries()
  74. {
  75. // Setup
  76. $sample = TestResources::listQueuesMultipleEntries();
  77. // Test
  78. $actual = ListQueuesResult::create($sample);
  79. // Assert
  80. $queues = $actual->getQueues();
  81. $this->assertCount(2, $queues);
  82. $this->assertEquals($sample['Queues']['Queue'][0]['Name'], $queues[0]->getName());
  83. $this->assertEquals($sample['Queues']['Queue'][0]['Url'], $queues[0]->getUrl());
  84. $this->assertEquals($sample['Queues']['Queue'][1]['Name'], $queues[1]->getName());
  85. $this->assertEquals($sample['Queues']['Queue'][1]['Url'], $queues[1]->getUrl());
  86. $this->assertEquals($sample['MaxResults'], $actual->getMaxResults());
  87. $this->assertEquals($sample['NextMarker'], $actual->getNextMarker());
  88. return $actual;
  89. }
  90. /**
  91. * @covers WindowsAzure\Queue\Models\ListQueuesResult::getQueues
  92. * @depends testCreateWithMultipleEntries
  93. */
  94. public function testGetQueues($result)
  95. {
  96. // Test
  97. $actual = $result->getQueues();
  98. // Assert
  99. $this->assertCount(2, $actual);
  100. }
  101. /**
  102. * @covers WindowsAzure\Queue\Models\ListQueuesResult::setQueues
  103. * @depends testCreateWithMultipleEntries
  104. */
  105. public function testSetQueues($result)
  106. {
  107. // Setup
  108. $sample = new ListQueuesResult();
  109. $expected = $result->getQueues();
  110. // Test
  111. $sample->setQueues($expected);
  112. // Assert
  113. $this->assertEquals($expected, $sample->getQueues());
  114. $expected[0]->setName('test');
  115. $this->assertNotEquals($expected, $sample->getQueues());
  116. }
  117. /**
  118. * @covers WindowsAzure\Queue\Models\ListQueuesResult::setPrefix
  119. */
  120. public function testSetPrefix()
  121. {
  122. // Setup
  123. $options = new ListQueuesResult();
  124. $expected = 'myprefix';
  125. // Test
  126. $options->setPrefix($expected);
  127. // Assert
  128. $this->assertEquals($expected, $options->getPrefix());
  129. }
  130. /**
  131. * @covers WindowsAzure\Queue\Models\ListQueuesResult::getPrefix
  132. */
  133. public function testGetPrefix()
  134. {
  135. // Setup
  136. $options = new ListQueuesResult();
  137. $expected = 'myprefix';
  138. $options->setPrefix($expected);
  139. // Test
  140. $actual = $options->getPrefix();
  141. // Assert
  142. $this->assertEquals($expected, $actual);
  143. }
  144. /**
  145. * @covers WindowsAzure\Queue\Models\ListQueuesResult::setNextMarker
  146. */
  147. public function testSetNextMarker()
  148. {
  149. // Setup
  150. $options = new ListQueuesResult();
  151. $expected = 'mymarker';
  152. // Test
  153. $options->setNextMarker($expected);
  154. // Assert
  155. $this->assertEquals($expected, $options->getNextMarker());
  156. }
  157. /**
  158. * @covers WindowsAzure\Queue\Models\ListQueuesResult::getNextMarker
  159. */
  160. public function testGetNextMarker()
  161. {
  162. // Setup
  163. $options = new ListQueuesResult();
  164. $expected = 'mymarker';
  165. $options->setNextMarker($expected);
  166. // Test
  167. $actual = $options->getNextMarker();
  168. // Assert
  169. $this->assertEquals($expected, $actual);
  170. }
  171. /**
  172. * @covers WindowsAzure\Queue\Models\ListQueuesResult::setMarker
  173. */
  174. public function testSetMarker()
  175. {
  176. // Setup
  177. $options = new ListQueuesResult();
  178. $expected = 'mymarker';
  179. // Test
  180. $options->setMarker($expected);
  181. // Assert
  182. $this->assertEquals($expected, $options->getMarker());
  183. }
  184. /**
  185. * @covers WindowsAzure\Queue\Models\ListQueuesResult::getMarker
  186. */
  187. public function testGetMarker()
  188. {
  189. // Setup
  190. $options = new ListQueuesResult();
  191. $expected = 'mymarker';
  192. $options->setMarker($expected);
  193. // Test
  194. $actual = $options->getMarker();
  195. // Assert
  196. $this->assertEquals($expected, $actual);
  197. }
  198. /**
  199. * @covers WindowsAzure\Queue\Models\ListQueuesResult::setMaxResults
  200. */
  201. public function testSetMaxResults()
  202. {
  203. // Setup
  204. $options = new ListQueuesResult();
  205. $expected = '3';
  206. // Test
  207. $options->setMaxResults($expected);
  208. // Assert
  209. $this->assertEquals($expected, $options->getMaxResults());
  210. }
  211. /**
  212. * @covers WindowsAzure\Queue\Models\ListQueuesResult::getMaxResults
  213. */
  214. public function testGetMaxResults()
  215. {
  216. // Setup
  217. $options = new ListQueuesResult();
  218. $expected = '3';
  219. $options->setMaxResults($expected);
  220. // Test
  221. $actual = $options->getMaxResults();
  222. // Assert
  223. $this->assertEquals($expected, $actual);
  224. }
  225. }