UtilsTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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-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. * 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-2015 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_Technorati
  38. */
  39. class Zend_Service_Technorati_UtilsTest extends Zend_Service_Technorati_TestCase
  40. {
  41. /**
  42. * @return void
  43. */
  44. public function testSetUriHttpInputNullReturnsNull()
  45. {
  46. $this->assertNull(Zend_Service_Technorati_Utils::normalizeUriHttp(null));
  47. }
  48. /**
  49. * @return void
  50. */
  51. public function testSetUriHttpInputInvalidSchemeFtpThrowsException()
  52. {
  53. $scheme = 'ftp';
  54. $inputInvalidScheme = "$scheme://example.com";
  55. try {
  56. Zend_Service_Technorati_Utils::normalizeUriHttp($inputInvalidScheme);
  57. $this->fail('Expected Zend_Service_Technorati_Exception not thrown');
  58. } catch (Zend_Service_Technorati_Exception $e) {
  59. $this->assertContains($scheme, $e->getMessage());
  60. }
  61. }
  62. /**
  63. * @return void
  64. */
  65. public function testSetDateInputNullReturnsNull()
  66. {
  67. $this->assertNull(Zend_Service_Technorati_Utils::normalizeDate(null));
  68. }
  69. /**
  70. * @return void
  71. */
  72. public function testSetDateInputDateInstanceReturnsInstance()
  73. {
  74. $date = new Zend_Date('2007-11-11 08:47:26 GMT');
  75. $result = Zend_Service_Technorati_Utils::normalizeDate($date);
  76. $this->assertTrue($result instanceof Zend_Date);
  77. $this->assertEquals($date, $result);
  78. }
  79. /**
  80. * @return void
  81. */
  82. public function testSetDateInputInvalidThrowsException()
  83. {
  84. $inputInvalid = "2007foo";
  85. try {
  86. Zend_Service_Technorati_Utils::normalizeDate($inputInvalid);
  87. $this->fail('Expected Zend_Service_Technorati_Exception not thrown');
  88. } catch (Zend_Service_Technorati_Exception $e) {
  89. $this->assertContains($inputInvalid, $e->getMessage());
  90. }
  91. }
  92. }