當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OperationCommand::setResponseParser方法代碼示例

本文整理匯總了PHP中Guzzle\Service\Command\OperationCommand::setResponseParser方法的典型用法代碼示例。如果您正苦於以下問題:PHP OperationCommand::setResponseParser方法的具體用法?PHP OperationCommand::setResponseParser怎麽用?PHP OperationCommand::setResponseParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Guzzle\Service\Command\OperationCommand的用法示例。


在下文中一共展示了OperationCommand::setResponseParser方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSkipsUnkownModels

 public function testSkipsUnkownModels()
 {
     $parser = new OperationResponseParser();
     $operation = $this->getDescription()->getOperation('test');
     $operation->setResponseClass('Baz')->setResponseType('model');
     $op = new OperationCommand(array(), $operation);
     $op->setResponseParser($parser)->setClient(new Client());
     $op->prepare()->setResponse(new Response(201), true);
     $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $op->execute());
 }
開發者ID:xkeygmbh,項目名稱:ifresco-php,代碼行數:10,代碼來源:OperationResponseParserTest.php

示例2: testParsesResponsesWithResponseParser

 public function testParsesResponsesWithResponseParser()
 {
     $op = new OperationCommand(array(), new Operation());
     $p = $this->getMockBuilder('Guzzle\\Service\\Command\\ResponseParserInterface')->setMethods(array('parse'))->getMockForAbstractClass();
     $p->expects($this->once())->method('parse')->will($this->returnValue(array('foo' => 'bar')));
     $op->setResponseParser($p);
     $op->setClient(new Client());
     $request = $op->prepare();
     $request->setResponse(new Response(200), true);
     $this->assertEquals(array('foo' => 'bar'), $op->execute());
 }
開發者ID:jorjoh,項目名稱:Varden,代碼行數:11,代碼來源:OperationCommandTest.php

示例3: testDoesNotParseXmlWhenNotUsingXmlVisitor

 public function testDoesNotParseXmlWhenNotUsingXmlVisitor()
 {
     $parser = OperationResponseParser::getInstance();
     $description = ServiceDescription::factory(array('operations' => array('test' => array('responseClass' => 'Foo')), 'models' => array('Foo' => array('type' => 'object', 'properties' => array('baz' => array('location' => 'body'))))));
     $operation = $description->getOperation('test');
     $op = new OperationCommand(array(), $operation);
     $op->setResponseParser($parser)->setClient(new Client());
     $brokenXml = '<broken><><><<xml>>>>>';
     $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/xml'), $brokenXml), true);
     $result = $op->execute();
     $this->assertEquals(array('baz'), $result->getKeys());
     $this->assertEquals($brokenXml, (string) $result['baz']);
 }
開發者ID:KANU82,項目名稱:guzzle,代碼行數:13,代碼來源:OperationResponseParserTest.php

示例4: testAdditionalPropertiesWithRefAreResolved

 /**
  * @group issue-399
  * @link https://github.com/guzzle/guzzle/issues/501
  */
 public function testAdditionalPropertiesWithRefAreResolved()
 {
     $parser = OperationResponseParser::getInstance();
     $description = ServiceDescription::factory(array('operations' => array('test' => array('responseClass' => 'Foo')), 'models' => array('Baz' => array('type' => 'string'), 'Foo' => array('type' => 'object', 'additionalProperties' => array('$ref' => 'Baz', 'location' => 'json')))));
     $operation = $description->getOperation('test');
     $op = new OperationCommand(array(), $operation);
     $op->setResponseParser($parser)->setClient(new Client());
     $json = '{"a":"a","b":"b","c":"c"}';
     $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), $json), true);
     $result = $op->execute()->toArray();
     $this->assertEquals(array('a' => 'a', 'b' => 'b', 'c' => 'c'), $result);
 }
開發者ID:rahilmomin,項目名稱:ci_bootstrap_3,代碼行數:16,代碼來源:OperationResponseParserTest.php

示例5: testEnsuresResponseClassImplementsResponseClassInterface

 /**
  * @expectedException \Guzzle\Service\Exception\ResponseClassException
  * @expectedExceptionMessage and implement
  */
 public function testEnsuresResponseClassImplementsResponseClassInterface()
 {
     $parser = OperationResponseParser::getInstance();
     $description = ServiceDescription::factory(array('operations' => array('test' => array('responseClass' => __CLASS__))));
     $operation = $description->getOperation('test');
     $op = new OperationCommand(array(), $operation);
     $op->setResponseParser($parser)->setClient(new Client());
     $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), 'hi!'), true);
     $op->execute();
 }
開發者ID:mickdane,項目名稱:zidisha,代碼行數:14,代碼來源:OperationResponseParserTest.php


注:本文中的Guzzle\Service\Command\OperationCommand::setResponseParser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。