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


PHP Factory::createRequest方法代码示例

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


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

示例1: testCreateFactory

 public function testCreateFactory()
 {
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $request = $factory->createRequest('getRequestMock');
     $this->assertInstanceOf('\\Sokil\\Rest\\Client\\Request', $request);
 }
开发者ID:sokil,项目名称:php-rest,代码行数:7,代码来源:FactoryTest.php

示例2: testBehaviorOwner

 public function testBehaviorOwner()
 {
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $factory->attachBehavior('my', new \Sokil\Rest\Client\MyBehavior());
     // exec behavior
     $requert = $factory->createRequest('GetRequestMock');
     $this->assertEquals('http://localhost/some/resource', $requert->getRequestUrl());
 }
开发者ID:sokil,项目名称:php-rest,代码行数:9,代码来源:FactoryBehaviorTest.php

示例3: testOnError

 /**
  * @expectedException \Guzzle\Http\Exception\BadResponseException
  */
 public function testOnError()
 {
     // replace response
     $plugin = new \Guzzle\Plugin\Mock\MockPlugin();
     $plugin->addResponse(new \Guzzle\Http\Message\Response(404, array('Content-type' => 'application/json'), json_encode(array('error' => 0))));
     $factory = new Factory('http://localhost/');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $factory->addSubscriber($plugin);
     $status = new \stdclass();
     $status->status = 0;
     $factory->onError(function ($event) use($status) {
         $status->status = $event['response']->getStatusCode();
     });
     // send
     $request = $factory->createRequest('GetRequestMock');
     try {
         $response = $request->send();
     } catch (\Exception $e) {
         // check if event occured
         $this->assertEquals(404, $status->status);
         throw $e;
     }
 }
开发者ID:sokil,项目名称:php-rest,代码行数:26,代码来源:FactoryEventTest.php

示例4: testBuildUrlForRequest

 public function testBuildUrlForRequest()
 {
     // configure subscriber
     $factory = new Factory('http://localhost/basepath');
     $factory->setRequestClassNamespace('\\Sokil\\Rest\\Client\\RequestMock');
     $request = $factory->createRequest('GetRequestMock');
     $this->assertEquals('http://localhost/basepath/some/resource', $request->getUrl());
 }
开发者ID:sokil,项目名称:php-rest,代码行数:8,代码来源:RequestTest.php


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