PageRenderTime 77ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/skudatech/azure-sdk-for-php
PHP | 159 lines | 60 code | 25 blank | 74 comment | 0 complexity | b8632b59849a0bd1283a7ce18306f307 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\Queue;
  25. use Tests\Framework\TestResources;
  26. /**
  27. * Unit tests for class Queue
  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 QueueTest extends \PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * @covers WindowsAzure\Queue\Models\Queue::__construct
  41. */
  42. public function test__construct()
  43. {
  44. // Setup
  45. $expectedName = TestResources::QUEUE1_NAME;
  46. $expectedUrl = TestResources::QUEUE_URI;
  47. // Test
  48. $queue = new Queue($expectedName, $expectedUrl);
  49. // Assert
  50. $this->assertEquals($expectedName, $queue->getName());
  51. $this->assertEquals($expectedUrl, $queue->getUrl());
  52. }
  53. /**
  54. * @covers WindowsAzure\Queue\Models\Queue::setName
  55. */
  56. public function testSetName()
  57. {
  58. // Setup
  59. $queue = new Queue('myqueue', 'myurl');
  60. $expected = TestResources::QUEUE1_NAME;
  61. // Test
  62. $queue->setName($expected);
  63. // Assert
  64. $this->assertEquals($expected, $queue->getName());
  65. }
  66. /**
  67. * @covers WindowsAzure\Queue\Models\Queue::getName
  68. */
  69. public function testGetName()
  70. {
  71. // Setup
  72. $queue = new Queue('myqueue', 'myurl');
  73. $expected = TestResources::QUEUE1_NAME;
  74. $queue->setName($expected);
  75. // Test
  76. $actual = $queue->getName();
  77. // Assert
  78. $this->assertEquals($expected, $actual);
  79. }
  80. /**
  81. * @covers WindowsAzure\Queue\Models\Queue::setUrl
  82. */
  83. public function testSetUrl()
  84. {
  85. // Setup
  86. $queue = new Queue('myqueue', 'myurl');
  87. $expected = TestResources::QUEUE1_NAME;
  88. // Test
  89. $queue->setUrl($expected);
  90. // Assert
  91. $this->assertEquals($expected, $queue->getUrl());
  92. }
  93. /**
  94. * @covers WindowsAzure\Queue\Models\Queue::getUrl
  95. */
  96. public function testGetUrl()
  97. {
  98. // Setup
  99. $queue = new Queue('myqueue', 'myurl');
  100. $expected = TestResources::QUEUE_URI;
  101. $queue->setUrl($expected);
  102. // Test
  103. $actual = $queue->getUrl();
  104. // Assert
  105. $this->assertEquals($expected, $actual);
  106. }
  107. /**
  108. * @covers WindowsAzure\Queue\Models\Queue::setMetadata
  109. */
  110. public function testSetMetadata()
  111. {
  112. // Setup
  113. $queue = new Queue('myqueue', 'myurl');
  114. $expected = array('key1' => 'value1', 'key2' => 'value2');
  115. // Test
  116. $queue->setMetadata($expected);
  117. // Assert
  118. $this->assertEquals($expected, $queue->getMetadata());
  119. }
  120. /**
  121. * @covers WindowsAzure\Queue\Models\Queue::getMetadata
  122. */
  123. public function testGetMetadata()
  124. {
  125. // Setup
  126. $queue = new Queue('myqueue', 'myurl');
  127. $expected = array('key1' => 'value1', 'key2' => 'value2');
  128. $queue->setMetadata($expected);
  129. // Test
  130. $actual = $queue->getMetadata();
  131. // Assert
  132. $this->assertEquals($expected, $actual);
  133. }
  134. }