• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Sabre_HTTP_Request类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Sabre_HTTP_Request的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_HTTP_Request类的具体用法?PHP Sabre_HTTP_Request怎么用?PHP Sabre_HTTP_Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Sabre_HTTP_Request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testExpand

    function testExpand()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = Sabre_VObject_Reader::read($body);
        // We only expect 3 events
        $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: ' . $body);
        // TZID should be gone
        $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID']));
    }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:29,代码来源:ExpandEventsDoubleEventsTest.php


示例2: testCorrect

    function testCorrect()
    {
        $xml = '<?xml version="1.0"?>
<d:principal-search-property-set xmlns:d="DAV:"/>';
        $serverVars = array('REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals');
        $request = new Sabre_HTTP_Request($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals('HTTP/1.1 200 Ok', $server->httpResponse->status, $server->httpResponse->body);
        $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $server->httpResponse->headers);
        $check = array('/d:principal-search-property-set', '/d:principal-search-property-set/d:principal-search-property', '/d:principal-search-property-set/d:principal-search-property/d:prop', '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname', '/d:principal-search-property-set/d:principal-search-property/d:description');
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        foreach ($check as $v1 => $v2) {
            $xpath = is_int($v1) ? $v2 : $v1;
            $result = $xml->xpath($xpath);
            $count = 1;
            if (!is_int($v1)) {
                $count = $v2;
            }
            $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
        }
    }
开发者ID:Gninety,项目名称:Microweber,代码行数:25,代码来源:PrincipalSearchPropertySetTest.php


示例3: testQueryTimerange

    function testQueryTimerange()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120226T230000Z" end="20120228T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120226T230000Z" end="20120228T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        if (strpos($response->body, 'BEGIN:VCALENDAR') === false) {
            $this->fail('Got no events instead of 1. Output: ' . $response->body);
        }
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        // We expect 1 event
        $this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:30,代码来源:GetEventsByTimerangeTest.php


示例4: testIssue205

    function testIssue205()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:comp-filter name="VALARM">
                    <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
                </C:comp-filter>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: ' . $response->body);
        $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        $this->assertEquals(1, count($vObject->VEVENT));
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:30,代码来源:Issue205Test.php


示例5: testExpand

    /**
     * @depends testSimple
     */
    function testExpand()
    {
        $xml = '<?xml version="1.0"?>
<d:expand-property xmlns:d="DAV:">
  <d:property name="current-user-principal">
      <d:property name="displayname" />
  </d:property>
</d:expand-property>';
        $serverVars = array('REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/');
        $request = new Sabre_HTTP_Request($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status);
        $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $server->httpResponse->headers);
        $check = array('/d:multistatus', '/d:multistatus/d:response' => 1, '/d:multistatus/d:response/d:href' => 1, '/d:multistatus/d:response/d:propstat' => 1, '/d:multistatus/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat/d:prop/d:displayname' => 1);
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        foreach ($check as $v1 => $v2) {
            $xpath = is_int($v1) ? $v2 : $v1;
            $result = $xml->xpath($xpath);
            $count = 1;
            if (!is_int($v1)) {
                $count = $v2;
            }
            $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
        }
    }
开发者ID:Gninety,项目名称:Microweber,代码行数:32,代码来源:ExpandPropertiesTest.php


示例6: sendPROPFIND

 public function sendPROPFIND($body)
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'PROPFIND', 'HTTP_DEPTH' => '0');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:8,代码来源:SupportedReportSetTest.php


示例7: testGetAbsoluteUri

 function testGetAbsoluteUri()
 {
     $s = array('HTTP_HOST' => 'sabredav.org', 'REQUEST_URI' => '/foo');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('http://sabredav.org/foo', $r->getAbsoluteUri());
     $s = array('HTTP_HOST' => 'sabredav.org', 'REQUEST_URI' => '/foo', 'HTTPS' => 'on');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('https://sabredav.org/foo', $r->getAbsoluteUri());
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:9,代码来源:RequestTest.php


示例8: testGetQueryString

 function testGetQueryString()
 {
     $s = array('QUERY_STRING' => 'bla');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('bla', $r->getQueryString());
     $s = array();
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('', $r->getQueryString());
 }
开发者ID:rolwi,项目名称:koala,代码行数:9,代码来源:RequestTest.php


示例9: testPatchSuccess

 public function testPatchSuccess()
 {
     $this->node->put('00000000');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/partial', 'HTTP_X_UPDATE_RANGE' => 'bytes=3-5', 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', 'HTTP_CONTENT_LENGTH' => 3));
     $request->setBody('111');
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body);
     $this->assertEquals('00111000', $this->node->get());
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:9,代码来源:PluginTest.php


示例10: testCollectionGet

 function testCollectionGet()
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8', 'DAV' => '1, 3, extended-mkcol'), $this->response->headers);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body);
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:10,代码来源:MapGetToPropFindTest.php


示例11: testUpdateFileParsableBody

 function testUpdateFileParsableBody()
 {
     $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics'));
     $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n");
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
     $expected = array('uri' => 'blabla.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", 'calendarid' => 'calendar1');
     $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:10,代码来源:ValidateICalTest.php


示例12: testUpdateFileParsableBody

 function testUpdateFileParsableBody()
 {
     $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf'));
     $body = "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n";
     $request->setBody($body);
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
     $expected = array('uri' => 'blabla.vcf', 'carddata' => $body);
     $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:11,代码来源:ValidateVCardTest.php


示例13: testPutFail

 function testPutFail()
 {
     $serverVars = array('REQUEST_URI' => '/testput.txt', 'REQUEST_METHOD' => 'PUT', 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status);
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $this->response->headers);
     $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:11,代码来源:ServerFinderBlockTest.php


示例14: testPutUpdate

 function testPutUpdate()
 {
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('Testing updated file');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('0', $this->response->headers['Content-Length']);
     $this->assertEquals('HTTP/1.1 204 No Content', $this->response->status);
     $this->assertEquals('', $this->response->body);
     $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:12,代码来源:ServerTest.php


示例15: testReportPassThrough

 function testReportPassThrough()
 {
     $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
     $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
     $fakeServer->addPlugin($plugin);
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/'));
     $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
     $fakeServer->httpRequest = $request;
     $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock();
     $fakeServer->exec();
     $this->assertEquals('HTTP/1.1 501 Not Implemented', $fakeServer->httpResponse->status);
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:12,代码来源:PluginTest.php


示例16: testDigestAuthInt

 public function testDigestAuthInt()
 {
     $this->auth->setQOP(Sabre_HTTP_DigestAuth::QOP_AUTHINT | Sabre_HTTP_DigestAuth::QOP_AUTH);
     list($nonce, $opaque) = $this->getServerTokens(Sabre_HTTP_DigestAuth::QOP_AUTHINT | Sabre_HTTP_DigestAuth::QOP_AUTH);
     $username = 'admin';
     $password = 12345;
     $nc = '00003';
     $cnonce = uniqid();
     $digestHash = md5(md5($username . ':' . self::REALM . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . 'auth-int:' . md5('POST' . ':' . '/' . ':' . md5('body')));
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'POST', 'PHP_AUTH_DIGEST' => 'username="' . $username . '", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth-int,nc=' . $nc . ',cnonce="' . $cnonce . '"'));
     $request->setBody('body');
     $this->auth->setHTTPRequest($request);
     $this->auth->init();
     $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)), 'Authentication is deemed invalid through validateA1');
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:15,代码来源:DigestAuthTest.php


示例17: testIssue203

    function testIssue203()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        $this->assertEquals(2, count($vObject->VEVENT));
        $expectedEvents = array(array('DTSTART' => '20120326T135200Z', 'DTEND' => '20120326T145200Z', 'SUMMARY' => 'original summary'), array('DTSTART' => '20120328T135200Z', 'DTEND' => '20120328T145200Z', 'SUMMARY' => 'overwritten summary', 'RECURRENCE-ID' => '20120327T135200Z'));
        // try to match agains $expectedEvents array
        foreach ($expectedEvents as $expectedEvent) {
            $matching = false;
            foreach ($vObject->VEVENT as $vevent) {
                /** @var $vevent Sabre\VObject\Component\VEvent */
                foreach ($vevent->children as $child) {
                    /** @var $child Sabre\VObject\Property */
                    if (isset($expectedEvent[$child->name])) {
                        if ($expectedEvent[$child->name] != $child->value) {
                            continue 2;
                        }
                    }
                }
                $matching = true;
                break;
            }
            $this->assertTrue($matching, 'Did not find the following event in the response: ' . var_export($expectedEvent, true));
        }
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:45,代码来源:Issue203Test.php


示例18: testEverything

 /**
  * @depends testTreeMove
  * @depends testCopyMoveInfo
  */
 function testEverything()
 {
     // Request object
     $serverVars = array('REQUEST_METHOD' => 'MOVE', 'REQUEST_URI' => '/webdav/foo', 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', 'HTTP_OVERWRITE' => 'F');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('');
     $response = new Sabre_HTTP_ResponseMock();
     // Server setup
     mkdir(SABRE_TEMPDIR . '/issue33');
     $dir = new Sabre_DAV_FS_Directory(SABRE_TEMPDIR . '/issue33');
     $dir->createDirectory('foo');
     $tree = new Sabre_DAV_ObjectTree($dir);
     $server = new Sabre_DAV_Server($tree);
     $server->setBaseUri('/webdav/');
     $server->httpRequest = $request;
     $server->httpResponse = $response;
     $server->exec();
     $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3')));
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:23,代码来源:Issue33Test.php


示例19: testMultiGet

    function testMultiGet()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'REQUEST_URI' => '/addressbooks/user1/book1'));
        $request->setBody('<?xml version="1.0"?>
<c:addressbook-multiget xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
    <d:prop>
      <d:getetag />
      <c:address-data />
    </d:prop>
    <d:href>/addressbooks/user1/book1/card1</d:href>
</c:addressbook-multiget>');
        $response = new Sabre_HTTP_ResponseMock();
        $this->server->httpRequest = $request;
        $this->server->httpResponse = $response;
        $this->server->exec();
        $this->assertEquals('HTTP/1.1 207 Multi-Status', $response->status, 'Incorrect status code. Full response body:' . $response->body);
        // using the client for parsing
        $client = new Sabre_DAV_Client(array('baseUri' => '/'));
        $result = $client->parseMultiStatus($response->body);
        $this->assertEquals(array('/addressbooks/user1/book1/card1' => array(200 => array('{DAV:}getetag' => '"' . md5("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD") . '"', '{urn:ietf:params:xml:ns:carddav}address-data' => "BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD"))), $result);
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:21,代码来源:MultiGetTest.php


示例20: testExpandRecurringByDayEvent

    function testExpandRecurringByDayEvent()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120210T230000Z" end="20120217T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120210T230000Z" end="20120217T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = Sabre_VObject_Reader::read($body);
        $this->assertEquals(2, count($vObject->VEVENT));
        // check if DTSTARTs and DTENDs are correct
        foreach ($vObject->VEVENT as $vevent) {
            /** @var $vevent Sabre_VObject_Component_VEvent */
            foreach ($vevent->children as $child) {
                /** @var $child Sabre_VObject_Property */
                if ($child->name == 'DTSTART') {
                    // DTSTART has to be one of two valid values
                    $this->assertContains($child->value, array('20120214T171500Z', '20120216T171500Z'), 'DTSTART is not a valid value: ' . $child->value);
                } elseif ($child->name == 'DTEND') {
                    // DTEND has to be one of two valid values
                    $this->assertContains($child->value, array('20120214T181500Z', '20120216T181500Z'), 'DTEND is not a valid value: ' . $child->value);
                }
            }
        }
    }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:40,代码来源:ExpandEventsDTSTARTandDTENDbyDayTest.php



注:本文中的Sabre_HTTP_Request类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SaeMysql类代码示例发布时间:2022-05-23
下一篇:
PHP Sabre_DAV_XMLUtil类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap