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


PHP Client::getCommand方法代码示例

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


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

示例1: testAllowsForJsonBasedArrayParamsFunctionalTest

 public function testAllowsForJsonBasedArrayParamsFunctionalTest()
 {
     $description = new ServiceDescription(array('operations' => array('test' => new Operation(array('httpMethod' => 'PUT', 'parameters' => array('data' => array('required' => true, 'filters' => 'json_encode', 'location' => 'body')))))));
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('test', array('data' => array('foo' => 'bar')));
     $request = $command->prepare();
     $this->assertEquals('{"foo":"bar"}', (string) $request->getBody());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:9,代码来源:ServiceDescriptionTest.php

示例2: testAllowsForJsonBasedArrayParamsFunctionalTest

 public function testAllowsForJsonBasedArrayParamsFunctionalTest()
 {
     $service = array('test' => new ApiCommand(array('method' => 'PUT', 'params' => array('data' => array('required' => true, 'type' => 'type:array', 'filters' => 'json_encode', 'location' => 'body')))));
     $description = new ServiceDescription($service);
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('test', array('data' => array('foo' => 'bar')));
     $request = $command->prepare();
     $this->assertEquals(json_encode(array('foo' => 'bar')), (string) $request->getBody());
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:10,代码来源:ServiceDescriptionTest.php

示例3: testValidatesAdditionalParameters

 public function testValidatesAdditionalParameters()
 {
     $description = ServiceDescription::factory(array('operations' => array('foo' => array('httpMethod' => 'PUT', 'parameters' => array('bar' => array('location' => 'header')), 'additionalParameters' => array('location' => 'json')))));
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('foo');
     $command['bar'] = 'test';
     $command['hello'] = 'abc';
     $request = $command->prepare();
     $this->assertEquals('test', (string) $request->getHeader('bar'));
     $this->assertEquals('{"hello":"abc"}', (string) $request->getBody());
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:12,代码来源:DefaultRequestSerializerTest.php

示例4: testVisitsLocationWithMultipleFiles

 public function testVisitsLocationWithMultipleFiles()
 {
     $description = ServiceDescription::factory(array('operations' => array('DoPost' => array('httpMethod' => 'POST', 'parameters' => array('foo' => array('location' => 'postFile', 'type' => array('string', 'array')))))));
     $this->getServer()->flush();
     $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length:0\r\n\r\n"));
     $client = new Client($this->getServer()->getUrl());
     $client->setDescription($description);
     $command = $client->getCommand('DoPost', array('foo' => array(__FILE__, __FILE__)));
     $command->execute();
     $received = $this->getServer()->getReceivedRequests();
     $this->assertContains('name="foo[0]";', $received[0]);
     $this->assertContains('name="foo[1]";', $received[0]);
 }
开发者ID:rahilmomin,项目名称:ci_bootstrap_3,代码行数:13,代码来源:PostFileVisitorTest.php

示例5: testValidatesAdditionalParameters

 /**
  * @expectedException \Guzzle\Service\Exception\ValidationException
  * @expectedExceptionMessage Validation errors: [abc] must be of type string
  */
 public function testValidatesAdditionalParameters()
 {
     $description = ServiceDescription::factory(array('operations' => array('foo' => array('parameters' => array('baz' => array('type' => 'integer')), 'additionalParameters' => array('type' => 'string')))));
     $client = new Client();
     $client->setDescription($description);
     $command = $client->getCommand('foo', array('abc' => false, 'command.headers' => array('foo' => 'bar')));
     $command->prepare();
 }
开发者ID:angelospanag,项目名称:thymisis,代码行数:12,代码来源:CommandTest.php

示例6: executeCommand

 /**
  * @param       $command
  * @param array $arguments
  *
  * @return array
  */
 public function executeCommand($command, $arguments = array())
 {
     $command = $this->client->getCommand($command, $arguments);
     return $this->client->execute($command);
     /*$command->getResponse()->json();*/
 }
开发者ID:dw250100785,项目名称:gitlab-api,代码行数:12,代码来源:Api.php

示例7: testThrowsExceptionWhenMissingCommand

 /**
  * @expectedException InvalidArgumentException
  */
 public function testThrowsExceptionWhenMissingCommand()
 {
     $client = new Client();
     $mock = $this->getMock('Guzzle\\Service\\Command\\Factory\\FactoryInterface');
     $mock->expects($this->any())->method('factory')->with($this->equalTo('test'))->will($this->returnValue(null));
     $client->setCommandFactory($mock);
     $client->getCommand('test');
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:11,代码来源:ClientTest.php

示例8: testAllowsPostFieldsAndFiles

 /**
  * @covers Guzzle\Service\Command\DynamicCommand::build
  */
 public function testAllowsPostFieldsAndFiles()
 {
     $service = new ServiceDescription(array('post_command' => new ApiCommand(array('method' => 'POST', 'uri' => '/key', 'params' => array('test' => array('location' => 'post_field'), 'test_2' => array('location' => 'post_field:foo'), 'test_3' => array('location' => 'post_file'))))));
     $client = new Client('http://www.test.com/api/v2');
     $client->setDescription($service);
     $command = $client->getCommand('post_command', array('test' => 'Hi!', 'test_2' => 'There', 'test_3' => __FILE__));
     $request = $command->prepare();
     $this->assertEquals('Hi!', $request->getPostField('test'));
     $this->assertEquals('There', $request->getPostField('foo'));
     $this->assertInternalType('array', $request->getPostFile('test_3'));
     $command = $client->getCommand('post_command', array('test_3' => new PostFile('baz', __FILE__)));
     $request = $command->prepare();
     $this->assertInternalType('array', $request->getPostFile('baz'));
 }
开发者ID:nickpeirson,项目名称:guzzle,代码行数:17,代码来源:DynamicCommandTest.php

示例9: testCanAddListenerToParseDomainObjects

 public function testCanAddListenerToParseDomainObjects()
 {
     $client = new Client();
     $client->setDescription(ServiceDescription::factory(array('operations' => array('test' => array('responseClass' => 'FooBazBar')))));
     $foo = new \stdClass();
     $client->getEventDispatcher()->addListener('command.parse_response', function ($e) use($foo) {
         $e['result'] = $foo;
     });
     $command = $client->getCommand('test');
     $command->prepare()->setResponse(new Response(200), true);
     $result = $command->execute();
     $this->assertSame($result, $foo);
 }
开发者ID:rahilmomin,项目名称:ci_bootstrap_3,代码行数:13,代码来源:OperationResponseParserTest.php

示例10: testUsesRelativePaths

 /**
  * @covers Guzzle\Service\Command\DynamicCommand::build
  */
 public function testUsesRelativePaths()
 {
     $service = new ServiceDescription(array('test_path' => new ApiCommand(array('method' => 'GET', 'path' => 'test/abc'))));
     $client = new Client('http://www.test.com/api/v2');
     $client->setDescription($service);
     $command = $client->getCommand('test_path');
     $request = $command->prepare();
     $this->assertEquals('/api/v2/test/abc', $request->getPath());
 }
开发者ID:MicroSDHC,项目名称:justinribeiro.com-examples,代码行数:12,代码来源:DynamicCommandTest.php

示例11: getCommand

 public function getCommand($name, array $args = array())
 {
     $default_headers = array('content-type' => 'application/json', 'accept' => 'application/json');
     $args['headers'] = array_merge($default_headers, isset($args['headers']) ? $args['headers'] : array());
     return parent::getCommand($name, $args);
 }
开发者ID:denocodon,项目名称:symfony-blog,代码行数:6,代码来源:GuzzleClient.php

示例12: testAllowsCustomVisitor

 /**
  * @covers Guzzle\Service\Command\DynamicCommand::addVisitor
  */
 public function testAllowsCustomVisitor()
 {
     $service = new ServiceDescription(array('foo' => new ApiCommand(array('params' => array('test' => array('location' => 'query'))))));
     $client = new Client();
     $client->setDescription($service);
     $command = $client->getCommand('foo', array('test' => 'hi'));
     // Flip query and header
     $command->addVisitor('query', new HeaderVisitor());
     $request = $command->prepare();
     $this->assertEquals('hi', (string) $request->getHeader('test'));
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:14,代码来源:DynamicCommandTest.php

示例13: api

 /**
  * Call Api
  *
  * @param string $command
  * @param array $parameters
  * @return array
  */
 public function api($command, $parameters = [])
 {
     $command = $this->client->getCommand($command, $parameters);
     return $command->execute();
 }
开发者ID:cocoiti,项目名称:qiita-php,代码行数:12,代码来源:Qiita.php


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