public function testFetchesNewTokenIfExpired() { $this->mockResolver->shouldReceive('getToken')->once(); //should use cached token $resolver = new RequestHandler($this->mockResolver); $resolver->read("test.com"); }
/** * @param RequestHandler $iForm * * @return string * @throws \Exception */ public function getToken(RequestHandler $iForm) { try { $this->validateEndpoint(); $params = $this->getParams(); $result = $this->check($iForm->create(self::$endpoint)->with(http_build_query($params))); } catch (\Exception $e) { $result = $e->getMessage(); } return $result; }
/** * @param RequestHandler $gateway * @param $url * @param array $params * * @return string * @throws \Exception */ public function fetchIncrement(RequestHandler $gateway, $url, $params = array()) { if (!isset($params['offset'])) { throw new \InvalidArgumentException("missing offset value"); } $request = $gateway->read($url, $params, true); $this->validate($request); static::$total = $this->getTotalDataCount($request); $this->reset(); return $request['body']; }