You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cacert-testmgr/external/ZendFramework-1.9.5/tests/Zend/Service/Nirvanix/Namespace/ImfsTest.php

122 lines
3.8 KiB
PHP

<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Service
* @subpackage Nirvanix
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ImfsTest.php 18287 2009-09-18 20:22:42Z padraic $
*/
/**
* @see Zend_Service_Nirvanix_Namespace_Imfs
*/
require_once 'Zend/Service/Nirvanix/Namespace/Imfs.php';
/**
* @see Zend_Service_Nirvanix_FunctionalTestCase
*/
require_once 'Zend/Service/Nirvanix/FunctionalTestCase.php';
/**
* @category Zend
* @package Zend_Service_Nirvanix
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @group Zend_Service
* @group Zend_Service_Nirvanix
*/
class Zend_Service_Nirvanix_Namespace_ImfsTest extends Zend_Service_Nirvanix_FunctionalTestCase
{
public function testInheritsFromNirvanixBase()
{
$imfs = new Zend_Service_Nirvanix_Namespace_Imfs();
$this->assertType('Zend_Service_Nirvanix_Namespace_Base', $imfs);
}
// putContents()
public function testPutContents()
{
$imfs = $this->nirvanix->getService('IMFS');
// response for call to GetStorageNode
$this->httpAdapter->addResponse(
$this->makeNirvanixResponse(
array('ResponseCode' => '0',
'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost>
<UploadToken>bar</UploadToken>'))
);
$imfs->putContents('/foo', 'contents for foo');
}
// getContents()
public function testGetContents()
{
$imfs = $this->nirvanix->getService('IMFS');
// response for call to GetOptimalUrlss
$this->httpAdapter->addResponse(
$this->makeNirvanixResponse(
array('ResponseCode' => '0',
'Download' => '<DownloadURL>http://get-it-here</DownloadURL>'))
);
// response for file download
$this->httpAdapter->addResponse(
$this->makeHttpResponseFrom('contents for foo')
);
$actual = $imfs->getContents('/foo.txt');
$expected = $this->httpClient->getLastResponse()->getBody();
$this->assertEquals($expected, $actual);
}
// unlink()
public function testUnlink()
{
$imfs = $this->nirvanix->getService('IMFS');
// response for call to DeleteFiles
$this->httpAdapter->addResponse(
$this->makeNirvanixResponse(array('ResponseCode' => '0'))
);
$imfs->unlink('foo');
}
/**
* @issue ZF-6860
*/
public function testDestinationPathFormatSentToServiceAsParameterUsesUnixConvention()
{
$imfs = $this->nirvanix->getService('IMFS');
$this->httpAdapter->addResponse(
$this->makeNirvanixResponse(
array('ResponseCode' => '0',
'GetStorageNode' => '<UploadHost>node1.nirvanix.com</UploadHost>
<UploadToken>bar</UploadToken>'))
);
// little unix cheat to force a backslash into the IFS path
$imfs->putContents('.\foo/bar', 'contents for foo');
$this->assertContains('./foo', $imfs->getHttpClient()->getLastRequest());
}
}