PageRenderTime 61ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/codes-php/phpjakarta/tests/unit/WindowsAzure/Common/Internal/Atom/AtomLinkTest.php

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