UtilsTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_Technorati
  17. * @subpackage UnitTests
  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__) . DIRECTORY_SEPARATOR . 'TestCase.php';
  26. /**
  27. * @see Zend_Service_Technorati_Utils
  28. */
  29. require_once "Zend/Service/Technorati/Utils.php";
  30. /**
  31. * @category Zend
  32. * @package Zend_Service_Technorati
  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_Technorati_UtilsTest extends Zend_Service_Technorati_TestCase
  38. {
  39. /**
  40. * @return void
  41. */
  42. public function testSetUriHttpInputNullReturnsNull()
  43. {
  44. $this->assertNull(Zend_Service_Technorati_Utils::normalizeUriHttp(null));
  45. }
  46. /**
  47. * @return void
  48. */
  49. public function testSetUriHttpInputInvalidSchemeFtpThrowsException()
  50. {
  51. $scheme = 'ftp';
  52. $inputInvalidScheme = "$scheme://example.com";
  53. try {
  54. Zend_Service_Technorati_Utils::normalizeUriHttp($inputInvalidScheme);
  55. $this->fail('Expected Zend_Service_Technorati_Exception not thrown');
  56. } catch (Zend_Service_Technorati_Exception $e) {
  57. $this->assertContains($scheme, $e->getMessage());
  58. }
  59. }
  60. /**
  61. * @return void
  62. */
  63. public function testSetDateInputNullReturnsNull()
  64. {
  65. $this->assertNull(Zend_Service_Technorati_Utils::normalizeDate(null));
  66. }
  67. /**
  68. * @return void
  69. */
  70. public function testSetDateInputDateInstanceReturnsInstance()
  71. {
  72. $date = new Zend_Date('2007-11-11 08:47:26 GMT');
  73. $result = Zend_Service_Technorati_Utils::normalizeDate($date);
  74. $this->assertType('Zend_Date', $result);
  75. $this->assertEquals($date, $result);
  76. }
  77. /**
  78. * @return void
  79. */
  80. public function testSetDateInputInvalidThrowsException()
  81. {
  82. $inputInvalid = "2007foo";
  83. try {
  84. Zend_Service_Technorati_Utils::normalizeDate($inputInvalid);
  85. $this->fail('Expected Zend_Service_Technorati_Exception not thrown');
  86. } catch (Zend_Service_Technorati_Exception $e) {
  87. $this->assertContains($inputInvalid, $e->getMessage());
  88. }
  89. }
  90. }