123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace OSS\Tests;
- use OSS\Model\RefererConfig;
- class RefererConfigTest extends \PHPUnit_Framework_TestCase
- {
- private $validXml = <<<BBBB
- <?xml version="1.0" encoding="utf-8"?>
- <RefererConfiguration>
- <AllowEmptyReferer>true</AllowEmptyReferer>
- <RefererList>
- <Referer>http://www.aliyun.com</Referer>
- <Referer>https://www.aliyun.com</Referer>
- <Referer>http://www.*.com</Referer>
- <Referer>https://www.?.aliyuncs.com</Referer>
- </RefererList>
- </RefererConfiguration>
- BBBB;
- private $validXml2 = <<<BBBB
- <?xml version="1.0" encoding="utf-8"?>
- <RefererConfiguration>
- <AllowEmptyReferer>true</AllowEmptyReferer>
- <RefererList>
- <Referer>http://www.aliyun.com</Referer>
- </RefererList>
- </RefererConfiguration>
- BBBB;
- public function testParseValidXml()
- {
- $refererConfig = new RefererConfig();
- $refererConfig->parseFromXml($this->validXml);
- $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml()));
- }
- public function testParseValidXml2()
- {
- $refererConfig = new RefererConfig();
- $refererConfig->parseFromXml($this->validXml2);
- $this->assertEquals(true, $refererConfig->isAllowEmptyReferer());
- $this->assertEquals(1, count($refererConfig->getRefererList()));
- $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($refererConfig)));
- }
- private function cleanXml($xml)
- {
- return str_replace("\n", "", str_replace("\r", "", $xml));
- }
- }
|