当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP\Sapi类代码示例

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


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

示例1: testExpand

    function testExpand()
    {
        $request = HTTP\Sapi::createFromServerArray(['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 = 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:pageer,项目名称:sabre-dav,代码行数:29,代码来源:ExpandEventsDoubleEventsTest.php

示例2: testCheckSuccess

 function testCheckSuccess()
 {
     $request = HTTP\Sapi::createFromServerArray(['PHP_AUTH_USER' => 'username', 'PHP_AUTH_PW' => 'password']);
     $response = new HTTP\Response();
     $backend = new AbstractBasicMock();
     $this->assertEquals([true, 'principals/username'], $backend->check($request, $response));
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:7,代码来源:AbstractBasicTest.php

示例3: 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 = HTTP\Sapi::createFromServerArray($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body);
        $this->assertEquals(array('X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Type' => ['application/xml; charset=utf-8']), $server->httpResponse->getHeaders());
        $check = array('/d:principal-search-property-set', '/d:principal-search-property-set/d:principal-search-property' => 2, '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1, '/d:principal-search-property-set/d:principal-search-property/d:description' => 2);
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        $xml->registerXPathNamespace('s', 'http://sabredav.org/ns');
        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:sebbie42,项目名称:casebox,代码行数:26,代码来源:PrincipalSearchPropertySetTest.php

示例4: testRedirectRemoteUser

 function testRedirectRemoteUser()
 {
     $request = HTTP\Sapi::createFromServerArray(['REDIRECT_REMOTE_USER' => 'username']);
     $response = new HTTP\Response();
     $backend = new Apache();
     $this->assertEquals([true, 'principals/username'], $backend->check($request, $response));
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:7,代码来源:ApacheTest.php

示例5: testPatchNoRange

 function testPatchNoRange()
 {
     $this->node->put('00000000');
     $request = HTTP\Sapi::createFromServerArray(['REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/partial']);
     $response = $this->request($request);
     $this->assertEquals(400, $response->status, 'Full response body:' . $response->body);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:7,代码来源:PluginTest.php

示例6: testUnsupportedMethod

 function testUnsupportedMethod()
 {
     $req = HTTP\Sapi::createFromServerArray(['REQUEST_METHOD' => 'POST', 'REQUEST_URI' => '/calendars/user1/outbox', 'HTTP_ORIGINATOR' => 'mailto:user1.sabredav@sabredav.org', 'HTTP_RECIPIENT' => 'mailto:user2@example.org', 'HTTP_CONTENT_TYPE' => 'text/calendar']);
     $body = ['BEGIN:VCALENDAR', 'METHOD:PUBLISH', 'BEGIN:VEVENT', 'END:VEVENT', 'END:VCALENDAR'];
     $req->setBody(implode("\r\n", $body));
     $this->assertHTTPStatus(501, $req);
 }
开发者ID:jakobsack,项目名称:sabre-dav,代码行数:7,代码来源:OutboxPostTest.php

示例7: substr

    function testIssue205()
    {
        $request = HTTP\Sapi::createFromServerArray(['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:BlaBlaNet,项目名称:hubzilla,代码行数:30,代码来源:Issue205Test.php

示例8: testCheckSuccess

 function testCheckSuccess()
 {
     $request = HTTP\Sapi::createFromServerArray(array('HTTP_AUTHORIZATION' => 'Bearer valid'));
     $response = new HTTP\Response();
     $backend = new AbstractBearerMock();
     $this->assertEquals([true, 'principals/username'], $backend->check($request, $response));
 }
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:7,代码来源:AbstractBearerTest.php

示例9: setUp

    function setUp()
    {
        $calendars = array(array('principaluri' => 'principals/user2', 'id' => 1, 'uri' => 'calendar1', '{' . CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => "BEGIN:VCALENDAR\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Berlin\r\nEND:VTIMEZONE\r\nEND:VCALENDAR"), array('principaluri' => 'principals/user2', 'id' => 2, 'uri' => 'calendar2', '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp(ScheduleCalendarTransp::TRANSPARENT)));
        $calendarobjects = array(1 => array('1.ics' => array('uri' => '1.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T130000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 1)), 2 => array('2.ics' => array('uri' => '2.ics', 'calendardata' => 'BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART:20110101T080000
DURATION:PT1H
END:VEVENT
END:VCALENDAR', 'calendarid' => 2)));
        $principalBackend = new DAVACL\PrincipalBackend\Mock();
        $this->caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
        $tree = array(new DAVACL\PrincipalCollection($principalBackend), new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend));
        $this->request = HTTP\Sapi::createFromServerArray(['CONTENT_TYPE' => 'text/calendar']);
        $this->response = new HTTP\ResponseMock();
        $this->server = new DAV\Server($tree);
        $this->server->httpRequest = $this->request;
        $this->server->httpResponse = $this->response;
        $this->aclPlugin = new DAVACL\Plugin();
        $this->server->addPlugin($this->aclPlugin);
        $authBackend = new DAV\Auth\Backend\Mock();
        $authBackend->setCurrentUser('user1');
        $this->authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV');
        $this->server->addPlugin($this->authPlugin);
        // CalDAV plugin
        $this->plugin = new CalDAV\Plugin();
        $this->server->addPlugin($this->plugin);
        // Scheduling plugin
        $this->plugin = new Plugin();
        $this->server->addPlugin($this->plugin);
    }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:35,代码来源:FreeBusyRequestTest.php

示例10: testException

 function testException()
 {
     $this->server->on('exception', [$this, 'exceptionHandler']);
     $req = HTTP\Sapi::createFromServerArray(['REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/not/exisitng']);
     $this->server->httpRequest = $req;
     $this->server->exec();
     $this->assertInstanceOf('Sabre\\DAV\\Exception\\NotFound', $this->exception);
 }
开发者ID:jakobsack,项目名称:sabre-dav,代码行数:8,代码来源:ServerEventsTest.php

示例11: testComplexIf

 function testComplexIf()
 {
     $serverVars = array('HTTP_IF' => '<http://www.example.org/node1> (<opaquelocktoken:token1> ["etag1"]) ' . '(Not <opaquelocktoken:token2>) (["etag2"]) <http://www.example.org/node2> ' . '(<opaquelocktoken:token3>) (Not <opaquelocktoken:token4>) (["etag3"])');
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $conditions = $this->server->getIfConditions($request);
     $compare = array(array('uri' => 'node1', 'tokens' => array(array('negate' => false, 'token' => 'opaquelocktoken:token1', 'etag' => '"etag1"'), array('negate' => true, 'token' => 'opaquelocktoken:token2', 'etag' => ''), array('negate' => false, 'token' => '', 'etag' => '"etag2"'))), array('uri' => 'node2', 'tokens' => array(array('negate' => false, 'token' => 'opaquelocktoken:token3', 'etag' => ''), array('negate' => true, 'token' => 'opaquelocktoken:token4', 'etag' => ''), array('negate' => false, 'token' => '', 'etag' => '"etag3"'))));
     $this->assertEquals($compare, $conditions);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:8,代码来源:GetIfConditionsTest.php

示例12: sendPROPFIND

 function sendPROPFIND($body)
 {
     $serverVars = ['REQUEST_URI' => '/', 'REQUEST_METHOD' => 'PROPFIND', 'HTTP_DEPTH' => '0'];
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:8,代码来源:SupportedReportSetTest.php

示例13: testPatchSuccess

 public function testPatchSuccess()
 {
     $this->node->put('00000000');
     $request = HTTP\Sapi::createFromServerArray(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(204, $response->status, 'Full response body:' . $response->body);
     $this->assertEquals('00011100', $this->node->get());
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:9,代码来源:PluginTest.php

示例14: testCheck

 function testCheck()
 {
     $digestHash = md5('HELLO:12345:1:1:auth:' . md5('GET:/'));
     $header = 'username=user, realm=myRealm, nonce=12345, uri=/, response=' . $digestHash . ', opaque=1, qop=auth, nc=1, cnonce=1';
     $request = HTTP\Sapi::createFromServerArray(array('REQUEST_METHOD' => 'GET', 'PHP_AUTH_DIGEST' => $header, 'REQUEST_URI' => '/'));
     $response = new HTTP\Response();
     $backend = new AbstractDigestMock();
     $this->assertEquals([true, 'principals/user'], $backend->check($request, $response));
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:9,代码来源:AbstractDigestTest.php

示例15: testCollectionGet

 function testCollectionGet()
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET');
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(207, $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body);
     $this->assertEquals(array('X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Type' => ['application/xml; charset=utf-8'], 'DAV' => ['1, 3, extended-mkcol'], 'Vary' => ['Brief,Prefer']), $this->response->getHeaders());
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:10,代码来源:MapGetToPropFindTest.php


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