SimplePostTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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-2009 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. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  26. /**
  27. * @see Zend_Service_Delicious_SimplePost
  28. */
  29. require_once 'Zend/Service/Delicious/SimplePost.php';
  30. /**
  31. * @category Zend_Service
  32. * @package Zend_Service_Delicious
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Service
  37. * @group Zend_Service_Delicious
  38. */
  39. class Zend_Service_Delicious_SimplePostTest extends PHPUnit_Framework_TestCase
  40. {
  41. /**
  42. * Ensures that the constructor throws an exception when the title is missing
  43. *
  44. * @return void
  45. */
  46. public function testConstructExceptionTitleMissing()
  47. {
  48. $post = array('u' => 'anything');
  49. try {
  50. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  51. $this->fail('Expected Zend_Service_Delicious_Exception not thrown');
  52. } catch (Zend_Service_Delicious_Exception $e) {
  53. $this->assertContains('Title and URL', $e->getMessage());
  54. }
  55. }
  56. /**
  57. * Ensures that the constructor throws an exception when the URL is missing
  58. *
  59. * @return void
  60. */
  61. public function testConstructExceptionUrlMissing()
  62. {
  63. $post = array('d' => 'anything');
  64. try {
  65. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  66. $this->fail('Expected Zend_Service_Delicious_Exception not thrown');
  67. } catch (Zend_Service_Delicious_Exception $e) {
  68. $this->assertContains('Title and URL', $e->getMessage());
  69. }
  70. }
  71. /**
  72. * Ensures that getUrl() behaves as expected
  73. *
  74. * @return void
  75. */
  76. public function testGetUrl()
  77. {
  78. $url = 'something';
  79. $post = array(
  80. 'd' => 'anything',
  81. 'u' => $url
  82. );
  83. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  84. $this->assertEquals(
  85. $url,
  86. $result = $simplePost->getUrl(),
  87. "Expected getUrl() to return '$url'; got '$result' instead"
  88. );
  89. }
  90. /**
  91. * Ensures that getTitle() behaves as expected
  92. *
  93. * @return void
  94. */
  95. public function testGetTitle()
  96. {
  97. $title = 'something';
  98. $post = array(
  99. 'd' => $title,
  100. 'u' => 'anything'
  101. );
  102. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  103. $this->assertEquals(
  104. $title,
  105. $result = $simplePost->getTitle(),
  106. "Expected getTitle() to return '$title'; got '$result' instead"
  107. );
  108. }
  109. /**
  110. * Ensures that getNotes() behaves as expected
  111. *
  112. * @return void
  113. */
  114. public function testGetNotes()
  115. {
  116. $notes = 'something';
  117. $post = array(
  118. 'd' => 'anything',
  119. 'u' => 'anything',
  120. 'n' => $notes
  121. );
  122. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  123. $this->assertEquals(
  124. $notes,
  125. $result = $simplePost->getNotes(),
  126. "Expected getNotes() to return '$notes'; got '$result' instead"
  127. );
  128. }
  129. /**
  130. * Ensures that getTags() behaves as expected
  131. *
  132. * @return void
  133. */
  134. public function testGetTags()
  135. {
  136. $tags = 'something';
  137. $post = array(
  138. 'd' => 'anything',
  139. 'u' => 'anything',
  140. 't' => $tags
  141. );
  142. $simplePost = new Zend_Service_Delicious_SimplePost($post);
  143. $this->assertEquals(
  144. $tags,
  145. $result = $simplePost->getTags(),
  146. "Expected getTags() to return '$tags'; got '$result' instead"
  147. );
  148. }
  149. }