You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResu...

67 lines
2.1 KiB

11 months ago
<?php
namespace OSS\Tests;
use OSS\Result\GetBucketRequestPaymentResult;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
class GetBucketRequestPaymentResultTest extends \PHPUnit\Framework\TestCase
{
private $validXml = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
<Payer>Requester</Payer>
</RequestPaymentConfiguration>
BBBB;
private $validXml2 = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
<Payer>BucketOwner</Payer>
</RequestPaymentConfiguration>
BBBB;
private $invalidXml = <<<BBBB
<?xml version="1.0" ?>
<RequestPaymentConfiguration>
</RequestPaymentConfiguration>
BBBB;
public function testParseValidXml()
{
$response = new ResponseCore(array(), $this->validXml, 200);
$result = new GetBucketRequestPaymentResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$payer = $result->getData();
$this->assertEquals("Requester", $payer);
$response = new ResponseCore(array(), $this->validXml2, 200);
$result = new GetBucketRequestPaymentResult($response);
$this->assertTrue($result->isOK());
$this->assertNotNull($result->getData());
$this->assertNotNull($result->getRawResponse());
$payer = $result->getData();
$this->assertEquals("BucketOwner", $payer);
}
public function testParseNullXml()
{
$response = new ResponseCore(array(), "", 200);
$result = new GetBucketRequestPaymentResult($response);
$payer = $result->getData();
$this->assertEquals(null, $payer);
}
public function testParseInvalidXml()
{
$response = new ResponseCore(array(), $this->invalidXml, 200);
$result = new GetBucketRequestPaymentResult($response);
$payer = $result->getData();
$this->assertEquals(null, $payer);
}
}