/**
  * @inheritdoc
  */
 public function test(Request $request)
 {
     $body = $request->getBody();
     return parent::test($request) && !empty($body) && !empty($body['grant_type']) && $body['grant_type'] == 'password';
 }
Example #2
0
 /**
  * Method verifies that mock is applicable for given Request
  * @param Request $request
  * @return string
  */
 public function test(Request $request)
 {
     return stristr($request->getUrl(), $this->path);
 }
 /**
  * @param Mocks        $mocks
  * @param string       $method
  * @param string       $url
  * @param array|null   $queryParams
  * @param array|string $body
  * @param array        $headers
  * @throws Exception
  */
 public function __construct(Mocks $mocks, $method, $url, $queryParams = array(), $body = null, array $headers = array())
 {
     parent::__construct($method, $url, $queryParams, $body, $headers);
     $this->mocks = $mocks;
 }
 public function testGetSetMethod()
 {
     $r = new Request('GET', 'http://whatever');
     $this->assertEquals('POST', $r->setMethod('POST')->getMethod());
 }
 /**
  * @inheritdoc
  */
 public function getResponse(Request $request)
 {
     $body = $request->getBody();
     return new Response(200, self::createBody(array('eventFilters' => $body['eventFilters'], 'expirationTime' => date('c', time() + $this->expiresIn), 'expiresIn' => $this->expiresIn, 'deliveryMode' => array('transportType' => 'PubNub', 'encryption' => false, 'address' => '123_foo', 'subscriberKey' => 'sub-c-foo', 'secretKey' => 'sec-c-bar'), 'id' => 'foo-bar-baz', 'creationTime' => date('c'), 'status' => 'Active', 'uri' => 'https=>//platform.ringcentral.com/restapi/v1.0/subscription/foo-bar-baz')));
 }
 /**
  * @param Request $request
  * @return Response
  * @throws HttpException
  */
 protected function authCall(Request $request)
 {
     return $request->setHeader(Request::AUTHORIZATION, 'Basic ' . $this->getApiKey())->setHeader(Request::CONTENT_TYPE, Request::URL_ENCODED_CONTENT_TYPE)->setUrl($this->apiUrl($request->getUrl(), array('addServer' => true)))->setMethod(Request::POST)->send();
 }