PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/unit/WindowsAzure/Blob/Models/CreateContainerOptionsTest.php

http://github.com/WindowsAzure/azure-sdk-for-php
PHP | 142 lines | 55 code | 20 blank | 67 comment | 0 complexity | b470ac67ace5ddca21702e32d743b8dd 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\Blob\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\Blob\Models;
  24. use WindowsAzure\Blob\Models\CreateContainerOptions;
  25. use WindowsAzure\Common\Internal\InvalidArgumentTypeException;
  26. /**
  27. * Unit tests for class CreateContainerOptions
  28. *
  29. * @category Microsoft
  30. * @package Tests\Unit\WindowsAzure\Blob\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 CreateContainerOptionsTest extends \PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::getPublicAccess
  41. */
  42. public function testGetPublicAccess()
  43. {
  44. // Setup
  45. $properties = new CreateContainerOptions();
  46. $expected = 'blob';
  47. $properties->setPublicAccess($expected);
  48. // Test
  49. $actual = $properties->getPublicAccess();
  50. // Assert
  51. $this->assertEquals($expected, $actual);
  52. }
  53. /**
  54. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::setPublicAccess
  55. */
  56. public function testSetPublicAccess()
  57. {
  58. // Setup
  59. $properties = new CreateContainerOptions();
  60. $expected = 'container';
  61. // Test
  62. $properties->setPublicAccess($expected);
  63. // Assert
  64. $actual = $properties->getPublicAccess();
  65. $this->assertEquals($expected, $actual);
  66. }
  67. /**
  68. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::setPublicAccess
  69. */
  70. public function testSetPublicAccessInvalidValueFail()
  71. {
  72. // Setup
  73. $properties = new CreateContainerOptions();
  74. $expected = new \DateTime();
  75. $this->setExpectedException(get_class(new InvalidArgumentTypeException('')));
  76. // Test
  77. $properties->setPublicAccess($expected);
  78. }
  79. /**
  80. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::setMetadata
  81. */
  82. public function testSetMetadata()
  83. {
  84. // Setup
  85. $container = new CreateContainerOptions();
  86. $expected = array('key1' => 'value1', 'key2' => 'value2');
  87. // Test
  88. $container->setMetadata($expected);
  89. // Assert
  90. $this->assertEquals($expected, $container->getMetadata());
  91. }
  92. /**
  93. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::getMetadata
  94. */
  95. public function testGetMetadata()
  96. {
  97. // Setup
  98. $container = new CreateContainerOptions();
  99. $expected = array('key1' => 'value1', 'key2' => 'value2');
  100. $container->setMetadata($expected);
  101. // Test
  102. $actual = $container->getMetadata();
  103. // Assert
  104. $this->assertEquals($expected, $actual);
  105. }
  106. /**
  107. * @covers WindowsAzure\Blob\Models\CreateContainerOptions::addMetadata
  108. */
  109. public function testAddMetadata()
  110. {
  111. // Setup
  112. $container = new CreateContainerOptions();
  113. $key = 'key1';
  114. $value = 'value1';
  115. $expected = array($key => $value);
  116. // Test
  117. $container->addMetadata($key, $value);
  118. // Assert
  119. $this->assertEquals($expected, $container->getMetadata());
  120. }
  121. }
  122. ?>