/** * curl error * @param \Guzzle\Common\Event $event * @throws KintoneException */ public function onRequestException(Event $event) { $this->request = $event->offsetGet('request'); $this->response = $event->offsetGet('response'); $this->exception = $event->offsetGet('exception'); if ($this->exception instanceof \Guzzle\Http\Exception\CurlException) { $errorNumber = $this->exception->getErrorNo(); switch ($errorNumber) { case 6: throw new KintoneException('kintone.unknown_url'); case 35: throw new KintoneException('kintone.invalid_cert'); default: throw new KintoneException('kintone.invalid_auth'); } } throw new \Exception($this->exception->getMessage()); }
public function it_adds_the_token_to_the_command_before_prepare(Event $event, CommandInterface $command) { /** @var EventDispatcher $dispatcher */ $dispatcher = $this->getEventDispatcher(); $event->offsetGet('command')->willReturn($command); $event->setDispatcher($dispatcher)->shouldBeCalled(); $event->setName('command.before_prepare')->shouldBeCalled(); $event->isPropagationStopped()->willReturn(false); $command->offsetSet('token', $this->config['token'])->shouldBeCalled(); $dispatcher->dispatch('command.before_prepare', $event); }
public function it_dispatches_before_send(Event $e, Request $request, Url $url, QueryString $q) { $e->offsetGet('request')->willReturn($request); $request->getUrl(true)->willReturn($url); $url->setHost(sprintf(LegacyUrlPlugin::BASE_URL, 'username'))->willReturn($url); $url->setPath(LegacyUrlPlugin::WEBHOOK_PATH)->willReturn($url); $url->setScheme('https')->willReturn($url); $request->setUrl($url)->shouldBeCalled()->willReturn($request); $request->getQuery()->shouldBeCalled()->willReturn($q); $this->onRequestBeforeSend($e)->shouldReturn(null); }