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

https://bitbucket.org/skudatech/azure-sdk-for-php · PHP · 670 lines · 317 code · 120 blank · 233 comment · 0 complexity · bd46ccd117badfca1cefe8f34703db7a 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\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. use WindowsAzure\Common\Internal\Atom\Content;
  26. use WindowsAzure\Common\Internal\Atom\Entry;
  27. use WindowsAzure\Common\Internal\Atom\Category;
  28. use WindowsAzure\Common\Internal\Atom\Person;
  29. use WindowsAzure\Common\Internal\Atom\Source;
  30. /**
  31. * Unit tests for class WrapAccessTokenResult
  32. *
  33. * @category Microsoft
  34. * @package Tests\Unit\WindowsAzure\Common\Internal\Atom
  35. * @author Azure PHP SDK <azurephpsdk@microsoft.com>
  36. * @copyright 2012 Microsoft Corporation
  37. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
  38. * @version Release: @package_version@
  39. * @link https://github.com/WindowsAzure/azure-sdk-for-php
  40. */
  41. class EntryTest extends \PHPUnit_Framework_TestCase
  42. {
  43. /**
  44. * @covers WindowsAzure\Common\Internal\Atom\Entry::__construct
  45. */
  46. public function testEntryConstructor()
  47. {
  48. // Setup
  49. // Test
  50. $entry = new Entry();
  51. // Assert
  52. $this->assertNotNull($entry);
  53. }
  54. /**
  55. * @covers WindowsAzure\Common\Internal\Atom\Entry::getAuthor
  56. * @covers WindowsAzure\Common\Internal\Atom\Entry::setAuthor
  57. */
  58. public function testEntryGetSetAuthor()
  59. {
  60. // Setup
  61. $expected = new Person();
  62. $expected->setName('testPerson');
  63. $entry = new Entry();
  64. // Test
  65. $entry->setAuthor($expected);
  66. $actual = $entry->getAuthor();
  67. // Assert
  68. $this->assertEquals(
  69. $expected->getName(),
  70. $actual->getName()
  71. );
  72. }
  73. /**
  74. * @covers WindowsAzure\Common\Internal\Atom\Entry::getCategory
  75. * @covers WindowsAzure\Common\Internal\Atom\Entry::setCategory
  76. */
  77. public function testEntryGetSetCategory()
  78. {
  79. // Setup
  80. $expected = new Category();
  81. $expected->setTerm('testTerm');
  82. $entry = new Entry();
  83. // Test
  84. $entry->setCategory($expected);
  85. $actual = $entry->getCategory();
  86. // Assert
  87. $this->assertEquals(
  88. $expected->getTerm(),
  89. $actual->getTerm()
  90. );
  91. }
  92. /**
  93. * @covers WindowsAzure\Common\Internal\Atom\Entry::getContent
  94. * @covers WindowsAzure\Common\Internal\Atom\Entry::setContent
  95. */
  96. public function testEntryGetSetContent()
  97. {
  98. // Setup
  99. $expected = new Content();
  100. $expected->setText('testText');
  101. $entry = new Entry();
  102. // Test
  103. $entry->setContent($expected);
  104. $actual = $entry->getContent();
  105. // Assert
  106. $this->assertEquals(
  107. $expected->getText(),
  108. $actual->getText()
  109. );
  110. }
  111. /**
  112. * @covers WindowsAzure\Common\Internal\Atom\Entry::getContributor
  113. * @covers WindowsAzure\Common\Internal\Atom\Entry::setContributor
  114. */
  115. public function testEntryGetSetContributor()
  116. {
  117. // Setup
  118. $expected = new Person();
  119. $expected->setName('testContributor');
  120. $entry = new Entry();
  121. // Test
  122. $entry->setContributor($expected);
  123. $actual = $entry->getContributor();
  124. // Assert
  125. $this->assertEquals(
  126. $expected->getName(),
  127. $actual->getName()
  128. );
  129. }
  130. /**
  131. * @covers WindowsAzure\Common\Internal\Atom\Entry::getId
  132. * @covers WindowsAzure\Common\Internal\Atom\Entry::setId
  133. */
  134. public function testEntryGetSetId()
  135. {
  136. // Setup
  137. $expected = 'testId';
  138. $entry = new Entry();
  139. // Test
  140. $entry->setId($expected);
  141. $actual = $entry->getId();
  142. // Assert
  143. $this->assertEquals(
  144. $expected,
  145. $actual
  146. );
  147. }
  148. /**
  149. * @covers WindowsAzure\Common\Internal\Atom\Entry::getLink
  150. * @covers WindowsAzure\Common\Internal\Atom\Entry::setLink
  151. */
  152. public function testEntryGetSetLink()
  153. {
  154. // Setup
  155. $expected = new AtomLink('testLink');
  156. $entry = new Entry();
  157. // Test
  158. $entry->setLink($expected);
  159. $actual = $entry->getLink();
  160. // Assert
  161. $this->assertEquals(
  162. $expected,
  163. $actual
  164. );
  165. }
  166. /**
  167. * @covers WindowsAzure\Common\Internal\Atom\Entry::getPublished
  168. * @covers WindowsAzure\Common\Internal\Atom\Entry::setPublished
  169. */
  170. public function testEntryGetSetPublished()
  171. {
  172. // Setup
  173. $expected = true;
  174. $entry = new Entry();
  175. // Test
  176. $entry->setPublished($expected);
  177. $actual = $entry->getPublished();
  178. // Assert
  179. $this->assertEquals(
  180. $expected,
  181. $actual
  182. );
  183. }
  184. /**
  185. * @covers WindowsAzure\Common\Internal\Atom\Entry::getRights
  186. * @covers WindowsAzure\Common\Internal\Atom\Entry::setRights
  187. */
  188. public function testEntryGetSetRights()
  189. {
  190. // Setup
  191. $expected = 'rights';
  192. $entry = new Entry();
  193. // Test
  194. $entry->setRights($expected);
  195. $actual = $entry->getRights();
  196. // Assert
  197. $this->assertEquals(
  198. $expected,
  199. $actual
  200. );
  201. }
  202. /**
  203. * @covers WindowsAzure\Common\Internal\Atom\Entry::getSource
  204. * @covers WindowsAzure\Common\Internal\Atom\Entry::setSource
  205. */
  206. public function testEntryGetSetSource()
  207. {
  208. // Setup
  209. $expected = new Source();
  210. $entry = new Entry();
  211. // Test
  212. $entry->setSource($expected);
  213. $actual = $entry->getSource();
  214. // Assert
  215. $this->assertEquals(
  216. $expected,
  217. $actual
  218. );
  219. }
  220. /**
  221. * @covers WindowsAzure\Common\Internal\Atom\Entry::getSummary
  222. * @covers WindowsAzure\Common\Internal\Atom\Entry::setSummary
  223. */
  224. public function testEntryGetSetSummary()
  225. {
  226. // Setup
  227. $expected = 'testSummary';
  228. $entry = new Entry();
  229. // Test
  230. $entry->setSummary($expected);
  231. $actual = $entry->getSummary();
  232. // Assert
  233. $this->assertEquals(
  234. $expected,
  235. $actual
  236. );
  237. }
  238. /**
  239. * @covers WindowsAzure\Common\Internal\Atom\Entry::getTitle
  240. * @covers WindowsAzure\Common\Internal\Atom\Entry::setTitle
  241. */
  242. public function testEntryGetSetTitle()
  243. {
  244. // Setup
  245. $expected = 'testTitle';
  246. $entry = new Entry();
  247. // Test
  248. $entry->setTitle($expected);
  249. $actual = $entry->getTitle();
  250. // Assert
  251. $this->assertEquals(
  252. $expected,
  253. $actual
  254. );
  255. }
  256. /**
  257. * @covers WindowsAzure\Common\Internal\Atom\Entry::getUpdated
  258. * @covers WindowsAzure\Common\Internal\Atom\Entry::setUpdated
  259. */
  260. public function testEntryGetSetUpdated()
  261. {
  262. // Setup
  263. $expected = true;
  264. $entry = new Entry();
  265. // Test
  266. $entry->setUpdated($expected);
  267. $actual = $entry->getUpdated();
  268. // Assert
  269. $this->assertEquals(
  270. $expected,
  271. $actual
  272. );
  273. }
  274. /**
  275. * @covers WindowsAzure\Common\Internal\Atom\Entry::getExtensionElement
  276. * @covers WindowsAzure\Common\Internal\Atom\Entry::setExtensionElement
  277. */
  278. public function testEntryGetSetExtensionElement()
  279. {
  280. // Setup
  281. $expected = 'testExtensionElement';
  282. $entry = new Entry();
  283. // Test
  284. $entry->setExtensionElement($expected);
  285. $actual = $entry->getExtensionElement();
  286. // Assert
  287. $this->assertEquals(
  288. $expected,
  289. $actual
  290. );
  291. }
  292. /**
  293. * @covers WindowsAzure\Common\Internal\Atom\Entry::writeXml
  294. */
  295. public function testEntryToXml()
  296. {
  297. // Setup
  298. $entry = new Entry();
  299. $expected = '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"/>';
  300. // Test
  301. $xmlWriter = new \XMLWriter();
  302. $xmlWriter->openMemory();
  303. $entry->writeXml($xmlWriter);
  304. $actual = $xmlWriter->outputMemory();
  305. // Assert
  306. $this->assertEquals(
  307. $expected,
  308. $actual
  309. );
  310. }
  311. /**
  312. * @covers WindowsAzure\Common\Internal\Atom\Entry::getAttributes
  313. * @covers WindowsAzure\Common\Internal\Atom\Entry::setAttributes
  314. */
  315. public function testGetSetAttributes() {
  316. // Setup
  317. $expected = array();
  318. $expected['testKey'] = 'testValue';
  319. $entry = new Entry();
  320. // Test
  321. $entry->setAttributes($expected);
  322. $actual = $entry->getAttributes();
  323. // Assert
  324. $this->assertEquals(
  325. $expected,
  326. $actual
  327. );
  328. }
  329. /**
  330. * @covers WindowsAzure\Common\Internal\Atom\Entry::getAuthor
  331. * @covers WindowsAzure\Common\Internal\Atom\Entry::setAuthor
  332. */
  333. public function testGetSetAuthor() {
  334. // Setup
  335. $expected = 'testAuthor';
  336. $entry = new Entry();
  337. // Test
  338. $entry->setAuthor($expected);
  339. $actual = $entry->getAuthor();
  340. // Assert
  341. $this->assertEquals(
  342. $expected,
  343. $actual
  344. );
  345. }
  346. /**
  347. * @covers WindowsAzure\Common\Internal\Atom\Entry::getCategory
  348. * @covers WindowsAzure\Common\Internal\Atom\Entry::setCategory
  349. */
  350. public function testGetSetCategory() {
  351. // Setup
  352. $expected = 'testCategory';
  353. $entry = new Entry();
  354. // Test
  355. $entry->setCategory($expected);
  356. $actual = $entry->getCategory();
  357. // Assert
  358. $this->assertEquals(
  359. $expected,
  360. $actual
  361. );
  362. }
  363. /**
  364. * @covers WindowsAzure\Common\Internal\Atom\Entry::getContent
  365. * @covers WindowsAzure\Common\Internal\Atom\Entry::setContent
  366. */
  367. public function testGetSetContent() {
  368. // Setup
  369. $expected = 'testContent';
  370. $entry = new Entry();
  371. // Test
  372. $entry->setContent($expected);
  373. $actual = $entry->getContent();
  374. // Assert
  375. $this->assertEquals(
  376. $expected,
  377. $actual
  378. );
  379. }
  380. /**
  381. * @covers WindowsAzure\Common\Internal\Atom\Entry::getContributor
  382. * @covers WindowsAzure\Common\Internal\Atom\Entry::setContributor
  383. */
  384. public function testGetSetContributor() {
  385. // Setup
  386. $expected = 'testContributor';
  387. $entry = new Entry();
  388. // Test
  389. $entry->setContributor($expected);
  390. $actual = $entry->getContributor();
  391. // Assert
  392. $this->assertEquals(
  393. $expected,
  394. $actual
  395. );
  396. }
  397. /**
  398. * @covers WindowsAzure\Common\Internal\Atom\Entry::getId
  399. * @covers WindowsAzure\Common\Internal\Atom\Entry::setId
  400. */
  401. public function testGetSetId() {
  402. // Setup
  403. $expected = 'testId';
  404. $entry = new Entry();
  405. // Test
  406. $entry->setId($expected);
  407. $actual = $entry->getId();
  408. // Assert
  409. $this->assertEquals(
  410. $expected,
  411. $actual
  412. );
  413. }
  414. /**
  415. * @covers WindowsAzure\Common\Internal\Atom\Entry::getLink
  416. * @covers WindowsAzure\Common\Internal\Atom\Entry::setLink
  417. */
  418. public function testGetSetLink() {
  419. // Setup
  420. $expected = 'testLink';
  421. $entry = new Entry();
  422. // Test
  423. $entry->setLink($expected);
  424. $actual = $entry->getLink();
  425. // Assert
  426. $this->assertEquals(
  427. $expected,
  428. $actual
  429. );
  430. }
  431. /**
  432. * @covers WindowsAzure\Common\Internal\Atom\Entry::getPublished
  433. * @covers WindowsAzure\Common\Internal\Atom\Entry::setPublished
  434. */
  435. public function testGetSetPublished() {
  436. // Setup
  437. $expected = 'testPublished';
  438. $entry = new Entry();
  439. // Test
  440. $entry->setPublished($expected);
  441. $actual = $entry->getPublished();
  442. // Assert
  443. $this->assertEquals(
  444. $expected,
  445. $actual
  446. );
  447. }
  448. /**
  449. * @covers WindowsAzure\Common\Internal\Atom\Entry::getRights
  450. * @covers WindowsAzure\Common\Internal\Atom\Entry::setRights
  451. */
  452. public function testGetSetRights() {
  453. // Setup
  454. $expected = 'testRights';
  455. $entry = new Entry();
  456. // Test
  457. $entry->setRights($expected);
  458. $actual = $entry->getRights();
  459. // Assert
  460. $this->assertEquals(
  461. $expected,
  462. $actual
  463. );
  464. }
  465. /**
  466. * @covers WindowsAzure\Common\Internal\Atom\Entry::getSource
  467. * @covers WindowsAzure\Common\Internal\Atom\Entry::setSource
  468. */
  469. public function testGetSetSource() {
  470. // Setup
  471. $expected = 'testSource';
  472. $entry = new Entry();
  473. // Test
  474. $entry->setSource($expected);
  475. $actual = $entry->getSource();
  476. // Assert
  477. $this->assertEquals(
  478. $expected,
  479. $actual
  480. );
  481. }
  482. /**
  483. * @covers WindowsAzure\Common\Internal\Atom\Entry::getSummary
  484. * @covers WindowsAzure\Common\Internal\Atom\Entry::setSummary
  485. */
  486. public function testGetSetSummary() {
  487. // Setup
  488. $expected = 'testSummary';
  489. $entry = new Entry();
  490. // Test
  491. $entry->setSummary($expected);
  492. $actual = $entry->getSummary();
  493. // Assert
  494. $this->assertEquals(
  495. $expected,
  496. $actual
  497. );
  498. }
  499. /**
  500. * @covers WindowsAzure\Common\Internal\Atom\Entry::getTitle
  501. * @covers WindowsAzure\Common\Internal\Atom\Entry::setTitle
  502. */
  503. public function testGetSetTitle() {
  504. // Setup
  505. $expected = 'testTitle';
  506. $entry = new Entry();
  507. // Test
  508. $entry->setTitle($expected);
  509. $actual = $entry->getTitle();
  510. // Assert
  511. $this->assertEquals(
  512. $expected,
  513. $actual
  514. );
  515. }
  516. /**
  517. * @covers WindowsAzure\Common\Internal\Atom\Entry::getUpdated
  518. * @covers WindowsAzure\Common\Internal\Atom\Entry::setUpdated
  519. */
  520. public function testGetSetUpdated() {
  521. // Setup
  522. $expected = 'testUpdated';
  523. $entry = new Entry();
  524. // Test
  525. $entry->setUpdated($expected);
  526. $actual = $entry->getUpdated();
  527. // Assert
  528. $this->assertEquals(
  529. $expected,
  530. $actual
  531. );
  532. }
  533. /**
  534. * @covers WindowsAzure\Common\Internal\Atom\Entry::getExtensionElement
  535. * @covers WindowsAzure\Common\Internal\Atom\Entry::setExtensionElement
  536. */
  537. public function testGetSetExtensionElement() {
  538. // Setup
  539. $expected = 'testExtensionElement';
  540. $entry = new Entry();
  541. // Test
  542. $entry->setExtensionElement($expected);
  543. $actual = $entry->getExtensionElement();
  544. // Assert
  545. $this->assertEquals(
  546. $expected,
  547. $actual
  548. );
  549. }
  550. }