SimplePostTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service_Delicious
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Service_Delicious_SimplePost
  24. */
  25. require_once 'Zend/Service/Delicious/SimplePost.php';
  26. /**
  27. * @category Zend_Service
  28. * @package Zend_Service_Delicious
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. * @group Zend_Service
  33. * @group Zend_Service_Delicious
  34. */
  35. class Zend_Service_Delicious_SimplePostTest extends PHPUnit_Framework_TestCase
  36. {
  37. /**
  38. * Ensures that the constructor throws an exception when the title is missing
  39. *
  40. * @return void
  41. */
  42. public function testConstructExceptionTitleMissing()
  43. {
  44. $post = array('u' => 'anything');
  45. try {
  46. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  47. $this->fail('Expected Zend_Service_Delicious_Exception not thrown');
  48. } catch (Zend_Service_Delicious_Exception $e) {
  49. $this->assertContains('Title and URL', $e->getMessage());
  50. }
  51. }
  52. /**
  53. * Ensures that the constructor throws an exception when the URL is missing
  54. *
  55. * @return void
  56. */
  57. public function testConstructExceptionUrlMissing()
  58. {
  59. $post = array('d' => 'anything');
  60. try {
  61. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  62. $this->fail('Expected Zend_Service_Delicious_Exception not thrown');
  63. } catch (Zend_Service_Delicious_Exception $e) {
  64. $this->assertContains('Title and URL', $e->getMessage());
  65. }
  66. }
  67. /**
  68. * Ensures that getUrl() behaves as expected
  69. *
  70. * @return void
  71. */
  72. public function testGetUrl()
  73. {
  74. $url = 'something';
  75. $post = array(
  76. 'd' => 'anything',
  77. 'u' => $url
  78. );
  79. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  80. $this->assertEquals(
  81. $url,
  82. $result = $simplePost->getUrl(),
  83. "Expected getUrl() to return '$url'; got '$result' instead"
  84. );
  85. }
  86. /**
  87. * Ensures that getTitle() behaves as expected
  88. *
  89. * @return void
  90. */
  91. public function testGetTitle()
  92. {
  93. $title = 'something';
  94. $post = array(
  95. 'd' => $title,
  96. 'u' => 'anything'
  97. );
  98. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  99. $this->assertEquals(
  100. $title,
  101. $result = $simplePost->getTitle(),
  102. "Expected getTitle() to return '$title'; got '$result' instead"
  103. );
  104. }
  105. /**
  106. * Ensures that getNotes() behaves as expected
  107. *
  108. * @return void
  109. */
  110. public function testGetNotes()
  111. {
  112. $notes = 'something';
  113. $post = array(
  114. 'd' => 'anything',
  115. 'u' => 'anything',
  116. 'n' => $notes
  117. );
  118. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  119. $this->assertEquals(
  120. $notes,
  121. $result = $simplePost->getNotes(),
  122. "Expected getNotes() to return '$notes'; got '$result' instead"
  123. );
  124. }
  125. /**
  126. * Ensures that getTags() behaves as expected
  127. *
  128. * @return void
  129. */
  130. public function testGetTags()
  131. {
  132. $tags = 'something';
  133. $post = array(
  134. 'd' => 'anything',
  135. 'u' => 'anything',
  136. 't' => $tags
  137. );
  138. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  139. $this->assertEquals(
  140. $tags,
  141. $result = $simplePost->getTags(),
  142. "Expected getTags() to return '$tags'; got '$result' instead"
  143. );
  144. }
  145. }