PageRenderTime 861ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/unit/WindowsAzure/Common/Internal/Atom/AtomLinkTest.php

http://github.com/WindowsAzure/azure-sdk-for-php
PHP | 265 lines | 121 code | 37 blank | 107 comment | 0 complexity | 29dc8a710d2ebf4409f007af59e24d8a 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. *
  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. *
  22. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  23. */
  24. namespace Tests\unit\WindowsAzure\Common\Internal\Atom;
  25. use WindowsAzure\Common\Internal\Atom\AtomLink;
  26. use PHPUnit\Framework\TestCase;
  27. /**
  28. * Unit tests for class AtomLink.
  29. *
  30. * @category Microsoft
  31. *
  32. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  33. * @copyright 2012 Microsoft Corporation
  34. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  35. *
  36. * @version Release: 0.5.0_2016-11
  37. *
  38. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  39. */
  40. class AtomLinkTest extends TestCase
  41. {
  42. /**
  43. */
  44. public function testAtomLinkConstructor()
  45. {
  46. // Setup
  47. // Test
  48. $feed = new AtomLink();
  49. // Assert
  50. $this->assertNotNull($feed);
  51. }
  52. /**
  53. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getUndefinedContent
  54. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setUndefinedContent
  55. */
  56. public function testGetSetUndefinedContent()
  57. {
  58. // Setup
  59. $expected = 'testUndefinedContent';
  60. $atomLink = new AtomLink();
  61. // Test
  62. $atomLink->setUndefinedContent($expected);
  63. $actual = $atomLink->getUndefinedContent();
  64. // Assert
  65. $this->assertEquals(
  66. $expected,
  67. $actual
  68. );
  69. }
  70. /**
  71. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getHref
  72. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setHref
  73. */
  74. public function testGetSetHref()
  75. {
  76. // Setup
  77. $expected = 'testHref';
  78. $atomLink = new AtomLink();
  79. // Test
  80. $atomLink->setHref($expected);
  81. $actual = $atomLink->getHref();
  82. // Assert
  83. $this->assertEquals(
  84. $expected,
  85. $actual
  86. );
  87. }
  88. /**
  89. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getRel
  90. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setRel
  91. */
  92. public function testGetSetRel()
  93. {
  94. // Setup
  95. $expected = 'testRel';
  96. $atomLink = new AtomLink();
  97. // Test
  98. $atomLink->setRel($expected);
  99. $actual = $atomLink->getRel();
  100. // Assert
  101. $this->assertEquals(
  102. $expected,
  103. $actual
  104. );
  105. }
  106. /**
  107. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getType
  108. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setType
  109. */
  110. public function testGetSetType()
  111. {
  112. // Setup
  113. $expected = 'testType';
  114. $atomLink = new AtomLink();
  115. // Test
  116. $atomLink->setType($expected);
  117. $actual = $atomLink->getType();
  118. // Assert
  119. $this->assertEquals(
  120. $expected,
  121. $actual
  122. );
  123. }
  124. /**
  125. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getHreflang
  126. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setHreflang
  127. */
  128. public function testGetSetHreflang()
  129. {
  130. // Setup
  131. $expected = 'testHreflang';
  132. $atomLink = new AtomLink();
  133. // Test
  134. $atomLink->setHreflang($expected);
  135. $actual = $atomLink->getHreflang();
  136. // Assert
  137. $this->assertEquals(
  138. $expected,
  139. $actual
  140. );
  141. }
  142. /**
  143. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getTitle
  144. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setTitle
  145. */
  146. public function testGetSetTitle()
  147. {
  148. // Setup
  149. $expected = 'testTitle';
  150. $atomLink = new AtomLink();
  151. // Test
  152. $atomLink->setTitle($expected);
  153. $actual = $atomLink->getTitle();
  154. // Assert
  155. $this->assertEquals(
  156. $expected,
  157. $actual
  158. );
  159. }
  160. /**
  161. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::getLength
  162. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::setLength
  163. */
  164. public function testGetSetLength()
  165. {
  166. // Setup
  167. $expected = 'testLength';
  168. $atomLink = new AtomLink();
  169. // Test
  170. $atomLink->setLength($expected);
  171. $actual = $atomLink->getLength();
  172. // Assert
  173. $this->assertEquals(
  174. $expected,
  175. $actual
  176. );
  177. }
  178. /**
  179. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::parseXml
  180. */
  181. public function testParseXmlSuccess()
  182. {
  183. // Setup
  184. $xml = '<link href="http://www.contonso.com"/>';
  185. $expected = new AtomLink();
  186. $expected->setHref('http://www.contonso.com');
  187. $actual = new AtomLink();
  188. // Test
  189. $actual->parseXml($xml);
  190. // Assert
  191. $this->assertEquals(
  192. $expected,
  193. $actual
  194. );
  195. }
  196. /**
  197. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::parseXml
  198. */
  199. public function testParseXmlInvalidArgument()
  200. {
  201. // Setup
  202. $this->setExpectedException(get_class(new \InvalidArgumentException()));
  203. $atomLink = new AtomLink();
  204. // Test
  205. $atomLink->parseXml(null);
  206. // Assert
  207. }
  208. /**
  209. * @covers \WindowsAzure\Common\Internal\Atom\AtomLink::writeXml
  210. */
  211. public function testWriteXmlSuccess()
  212. {
  213. // Setup
  214. $expected = '<atom:link href="http://www.contonso.com" xmlns:atom="http://www.w3.org/2005/Atom"/>';
  215. $atomLink = new AtomLink();
  216. $atomLink->setHref('http://www.contonso.com');
  217. // Test
  218. $xmlWriter = new \XMLWriter();
  219. $xmlWriter->openMemory();
  220. $atomLink->writeXml($xmlWriter);
  221. $actual = $xmlWriter->outputMemory();
  222. // Assert
  223. $this->assertEquals(
  224. $expected,
  225. $actual
  226. );
  227. }
  228. }