-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e26144
commit 31ad093
Showing
4 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace OSS\Tests; | ||
|
||
use OSS\Core\OssException; | ||
use OSS\OssClient; | ||
|
||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'TestOssClientBase.php'; | ||
|
||
|
||
class OssClientRestoreObjectTest extends TestOssClientBase | ||
{ | ||
private $IABucket; | ||
private $ArchiveBucket; | ||
|
||
public function testIARestoreObject() | ||
{ | ||
$object = 'storage-object'; | ||
|
||
$this->ossClient->putObject($this->IABucket, $object,'testcontent'); | ||
try{ | ||
$this->ossClient->restoreObject($this->IABucket, $object); | ||
$this->assertTrue(false); | ||
}catch (OssException $e){ | ||
$this->assertEquals('400', $e->getHTTPStatus()); | ||
$this->assertEquals('OperationNotSupported', $e->getErrorCode()); | ||
} | ||
} | ||
|
||
public function testNullObjectRestoreObject() | ||
{ | ||
$object = 'null-object'; | ||
|
||
try{ | ||
$this->ossClient->restoreObject($this->bucket, $object); | ||
$this->assertTrue(false); | ||
}catch (OssException $e){ | ||
$this->assertEquals('404', $e->getHTTPStatus()); | ||
} | ||
} | ||
|
||
public function testArchiveRestoreObject() | ||
{ | ||
$object = 'storage-object'; | ||
|
||
$this->ossClient->putObject($this->ArchiveBucket, $object,'testcontent'); | ||
try{ | ||
$this->ossClient->getObject($this->ArchiveBucket, $object); | ||
$this->assertTrue(false); | ||
}catch (OssException $e){ | ||
$this->assertEquals('403', $e->getHTTPStatus()); | ||
$this->assertEquals('InvalidObjectState', $e->getErrorCode()); | ||
} | ||
$result = $this->ossClient->restoreObject($this->ArchiveBucket, $object); | ||
common::waitMetaSync(); | ||
$this->assertEquals('202', $result['info']['http_code']); | ||
|
||
try{ | ||
$this->ossClient->restoreObject($this->ArchiveBucket, $object); | ||
}catch(OssException $e){ | ||
$this->assertEquals('409', $e->getHTTPStatus()); | ||
$this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); | ||
} | ||
} | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); // TODO: Change the autogenerated stub | ||
$this->IABucket = 'ia-'.$this->bucket; | ||
$this->ArchiveBucket = 'archive-'.$this->bucket; | ||
$this->ossClient->createBucket($this->IABucket, OssClient::OSS_ACL_TYPE_PRIVATE, NULL, OssClient::OSS_STORAGE_TYPE_IA); | ||
$this->ossClient->createBucket($this->ArchiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, NULL, OssClient::OSS_STORAGE_TYPE_ARCHIVE); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
parent::tearDown(); // TODO: Change the autogenerated stub | ||
$object = 'storage-object'; | ||
$this->ossClient->deleteObject($this->IABucket, $object); | ||
$this->ossClient->deleteObject($this->ArchiveBucket, $object); | ||
$this->ossClient->deleteBucket($this->IABucket); | ||
$this->ossClient->deleteBucket($this->ArchiveBucket); | ||
} | ||
} | ||
|
||
|
||
|