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


PHP Response::setContent方法代码示例

本文整理汇总了PHP中Buzz\Message\Response::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::setContent方法的具体用法?PHP Response::setContent怎么用?PHP Response::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Buzz\Message\Response的用法示例。


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

示例1: createResponse

 protected function createResponse($content = '')
 {
     $response = new Buzz\Message\Response();
     $response->addHeader('1.0 200 OK');
     $response->setContent($content);
     return $response;
 }
开发者ID:pampy,项目名称:PiwikClient,代码行数:7,代码来源:HttpConnectionTest.php

示例2: createResponse

 private function createResponse($content, $statusCode = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setHeaders(array('HTTP/1.1 ' . $statusCode . ' REASON'));
     return $response;
 }
开发者ID:wjzijderveld,项目名称:youless-client,代码行数:7,代码来源:ClientSpec.php

示例3: send

 /**
  * @see Client\ClientInterface
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if (!($queued = $this->receiveFromQueue())) {
         throw new \LogicException('There are no queued responses.');
     }
     $response->setHeaders($queued->getHeaders());
     $response->setContent($queued->getContent());
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:11,代码来源:AbstractQueue.php

示例4: testGetDomReturnsADomDocument

 public function testGetDomReturnsADomDocument()
 {
     $response = new Message\Response();
     $response->setContent('<html><head></head><body></body></html>');
     $this->browser->getClient()->sendToQueue($response);
     $this->browser->get('http://www.google.com');
     $this->assertTrue($this->browser->getDom() instanceof \DOMDocument);
 }
开发者ID:philip,项目名称:Buzz,代码行数:8,代码来源:BrowserTest.php

示例5: it_translates_a_text

 /**
  * @test
  */
 public function it_translates_a_text()
 {
     $response = new Response();
     $response->setContent('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">dit is een test</string>');
     $this->browser->expects($this->once())->method('get')->with('http://api.microsofttranslator.com/v2/Http.svc/Translate?from=en&to=nl&text=this+is+a+test')->willReturn($response);
     $translation = $this->translator->translate('en', 'nl', 'this is a test');
     $expectedTranslation = 'dit is een test';
     $this->assertEquals($expectedTranslation, $translation);
 }
开发者ID:dhensen,项目名称:translator,代码行数:12,代码来源:BingTranslatorTest.php

示例6: getSender

 /**
  * @return SenderInterface
  */
 private function getSender()
 {
     $client = $this->getMockBuilder('\\Team3\\PayU\\Communication\\Sender\\SenderInterface')->getMock();
     $client->expects($this->any())->method('send')->willReturnCallback(function () {
         $response = new Response();
         $response->setContent(self::RESPONSE_CONTENT);
         return $response;
     });
     return $client;
 }
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:13,代码来源:ClientTest.php

示例7: testGetBearerHeaderInvalidTokenTypeException

 public function testGetBearerHeaderInvalidTokenTypeException()
 {
     $twitter = $this->getMockBuilder('Endroid\\Twitter\\Twitter')->setConstructorArgs(array('foo', 'bar'))->setMethods(array('getBasicHeader', 'call'))->getMock();
     $twitter->expects($this->any())->method('getBasicHeader')->willReturn(self::EXPECTED_BASIC_HEADER);
     $response = new Response();
     $response->setContent(json_encode(array('token_type' => 'something_wrong', 'access_token' => 'cc4f26cc4a3f61a84436014b2166e431')));
     $twitter->expects($this->any())->method('call')->with('POST', Twitter::BASE_URL . Twitter::TOKEN_URL)->willReturn($response);
     $this->setExpectedException('Endroid\\Twitter\\Exception\\InvalidTokenTypeException');
     Util::invokeMethod($twitter, 'getBearerHeader');
 }
开发者ID:endroid,项目名称:twitter,代码行数:10,代码来源:TwitterTest.php

示例8: it_should_be_future_proof

 /**
  * @test
  */
 public function it_should_be_future_proof()
 {
     // google keeps putting more comma's to break peoples implementations
     $response = new Response();
     $response->setContent('[[["What are you doing?","Wat ben jij aan het doen?",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0]],,"nl"]');
     $this->browser->expects($this->once())->method('get')->with('https://translate.googleapis.com/translate_a/single?client=gtx&sl=nl&tl=en&dt=t&q=' . urlencode('Wat ben jij aan het doen?'))->willReturn($response);
     $translation = $this->translator->translate('nl', 'en', 'Wat ben jij aan het doen?');
     $expectedTranslation = 'What are you doing?';
     $this->assertEquals($expectedTranslation, $translation);
 }
开发者ID:dhensen,项目名称:translator,代码行数:13,代码来源:GoogleTranslatorUnofficialTest.php

示例9: getExportResponse

 protected function getExportResponse()
 {
     $zip = new \ZipArchive();
     $zip->open($this->zipFile, $zip::CREATE);
     $zip->addFile('test/etc/diary.csv', 'diary.csv');
     $zip->close();
     $response = new Response();
     $response->setHeaders(array('HTTP/1.1 200 OK', 'Content-Type: application/zip'));
     $response->setContent(file_get_contents($this->zipFile));
     return $response;
 }
开发者ID:cmbuckley,项目名称:letterboxd-ics,代码行数:11,代码来源:CalendarTest.php

示例10: testGetAuthTokenGivenCode

 /**
  * @test
  * @dataProvider getAuthCode
  */
 public function testGetAuthTokenGivenCode($code)
 {
     $response = new Response();
     $response->setContent('{"access_token": "ea135929105c4f29a0f5117d2960926f", "expires_in": 2592000}');
     $response->setHeaders(array('HTTP/1.1 200 OK'));
     $httpClient = $this->getHttpClientMock();
     $httpClient->expects($this->once())->method('post')->with($this->equalTo('https://oauth.yandex.ru/token'), $this->anything(), $this->stringContains($code))->will($this->returnValue($response));
     $auth = new Auth('test', 'test', $httpClient);
     $token = $auth->getAuthToken($code);
     $this->assertInstanceOf('\\Yandex\\Auth\\Token', $token);
     $this->assertEquals($token->getToken(), 'ea135929105c4f29a0f5117d2960926f');
 }
开发者ID:bubblehub,项目名称:php-yandex-webmaster-api,代码行数:16,代码来源:AuthTest.php

示例11: testGetStationBoardDelay

    public function testGetStationBoardDelay()
    {
        $response = new Response();
        $response->setContent(file_get_contents(__DIR__ . '/../../fixtures/archive/stationboard-2013-10-15.xml'));
        $this->browser->expects($this->once())->method('post')->with($this->equalTo('http://fahrplan.sbb.ch/bin/extxml.exe/'), $this->equalTo(array('User-Agent: SBBMobile/4.8 CFNetwork/609.1.4 Darwin/13.0.0', 'Accept: application/xml', 'Content-Type: application/xml')), $this->equalTo('<?xml version="1.0" encoding="iso-8859-1"?>
<ReqC lang="EN" prod="iPhone3.1" ver="2.3" accessId="vWjygiRIy0uclbLz4qDO7S3G4dcIIViwoLFCZlopGhe88vlsfedGIqctZP9lvqb"><STBReq boardType="DEP" maxJourneys="40"><Time>22:20</Time><Period><DateBegin><Date>20131015</Date></DateBegin><DateEnd><Date>20131015</Date></DateEnd></Period><TableStation externalId="008591052"/><ProductFilter>1111111111111111</ProductFilter></STBReq></ReqC>
'))->will($this->returnValue($response));
        $station = new Station('008591052');
        // Zürich, Bäckeranlage
        $journeys = $this->api->getStationBoard(new StationBoardQuery($station, \DateTime::createFromFormat(\DateTime::ISO8601, '2013-10-15T22:20:00+01:00')));
        $this->assertEquals(1, count($journeys));
        $this->assertEquals('2013-10-15T22:10:00+0100', $journeys[0]->stop->departure);
        $this->assertEquals(12, $journeys[0]->stop->delay);
    }
开发者ID:BJDev95,项目名称:Transport,代码行数:14,代码来源:APITest.php

示例12: testUsesTheLastQueuedResponse

 public function testUsesTheLastQueuedResponse()
 {
     $response1 = new Message\Response();
     $response1->setContent('first');
     $response2 = new Message\Response();
     $response2->setContent('last');
     $client = new LIFO();
     $client->sendToQueue($response1);
     $client->sendToQueue($response2);
     $request = new Message\Request();
     $response = new Message\Response();
     $client->send($request, $response);
     $this->assertEquals($response->getContent(), 'last');
 }
开发者ID:philip,项目名称:Buzz,代码行数:14,代码来源:LIFOTest.php

示例13: decompressContent

 private function decompressContent(\Buzz\Message\Response $response)
 {
     if (!($content_encoding = $response->getHeader('Content-Encoding'))) {
         return;
     }
     $content = $response->getContent();
     if (strpos($content_encoding, 'deflate') !== false) {
         $content = gzuncompress($content);
     }
     if (strpos($content_encoding, 'gzip') !== false) {
         $content = gzinflate(substr($content, 10));
     }
     $response->setContent($content);
 }
开发者ID:KaRpIkS,项目名称:torrent-announcer,代码行数:14,代码来源:Request.php

示例14: send

 /**
  * @see ClientInterface
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if ($cookieJar = $this->getCookieJar()) {
         $cookieJar->clearExpiredCookies();
         $cookieJar->addCookieHeaders($request);
     }
     $context = stream_context_create($this->getStreamContextArray($request));
     $content = file_get_contents($request->getUrl(), 0, $context);
     $response->setHeaders($http_response_header);
     $response->setContent($content);
     if ($cookieJar) {
         $cookieJar->processSetCookieHeaders($request, $response);
     }
 }
开发者ID:philip,项目名称:Buzz,代码行数:17,代码来源:FileGetContents.php

示例15: testSetsResponseHeadersAndContent

 public function testSetsResponseHeadersAndContent()
 {
     $response = new Message\Response();
     $response->addHeader('HTTP/1.0 200 OK');
     $response->setContent('Hello World!');
     $client = new FIFO();
     $client->setQueue(array($response));
     $client->sendToQueue($response);
     $this->assertEquals(count($client->getQueue()), 2);
     $request = new Message\Request();
     $response = new Message\Response();
     $client->send($request, $response);
     $this->assertEquals(count($client->getQueue()), 1);
     $this->assertEquals($response->getHeaders(), array('HTTP/1.0 200 OK'));
     $this->assertEquals($response->getContent(), 'Hello World!');
 }
开发者ID:philip,项目名称:Buzz,代码行数:16,代码来源:FIFOTest.php


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