SimplePostTest.php 4.4 KB

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