ImfsTest.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 Nirvanix
  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. */
  21. /**
  22. * @see Zend_Service_Nirvanix_Namespace_Imfs
  23. */
  24. require_once 'Zend/Service/Nirvanix/Namespace/Imfs.php';
  25. /**
  26. * @see Zend_Service_Nirvanix_FunctionalTestCase
  27. */
  28. require_once 'Zend/Service/Nirvanix/FunctionalTestCase.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Service
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_FunctionalTestCase
  37. {
  38. public function testInheritsFromNirvanixBase()
  39. {
  40. $imfs = new Zend_Service_Nirvanix_Namespace_Imfs();
  41. $this->assertType('Zend_Service_Nirvanix_Namespace_Base', $imfs);
  42. }
  43. // putContents()
  44. public function testPutContents()
  45. {
  46. $imfs = $this->nirvanix->getService('IMFS');
  47. // response for call to GetStorageNode
  48. $this->httpAdapter->addResponse(
  49. $this->makeNirvanixResponse(
  50. array('ResponseCode' => '0',
  51. 'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost>
  52. <UploadToken>bar</UploadToken>'))
  53. );
  54. $imfs->putContents('/foo', 'contents for foo');
  55. }
  56. // getContents()
  57. public function testGetContents()
  58. {
  59. $imfs = $this->nirvanix->getService('IMFS');
  60. // response for call to GetOptimalUrlss
  61. $this->httpAdapter->addResponse(
  62. $this->makeNirvanixResponse(
  63. array('ResponseCode' => '0',
  64. 'Download' => '<DownloadURL>http://get-it-here</DownloadURL>'))
  65. );
  66. // response for file download
  67. $this->httpAdapter->addResponse(
  68. $this->makeHttpResponseFrom('contents for foo')
  69. );
  70. $actual = $imfs->getContents('/foo.txt');
  71. $expected = $this->httpClient->getLastResponse()->getBody();
  72. $this->assertEquals($expected, $actual);
  73. }
  74. // unlink()
  75. public function testUnlink()
  76. {
  77. $imfs = $this->nirvanix->getService('IMFS');
  78. // response for call to DeleteFiles
  79. $this->httpAdapter->addResponse(
  80. $this->makeNirvanixResponse(array('ResponseCode' => '0'))
  81. );
  82. $imfs->unlink('foo');
  83. }
  84. }