/**
  * Test GET method with wrong Renderer class.
  */
 public function testGetWithWrongRendererClass()
 {
     $acceptTypes = ['application/json'];
     /** Mock request getAcceptTypes method to return specified value. */
     $this->_requestMock->expects($this->once())->method('getAcceptTypes')->will($this->returnValue($acceptTypes));
     /** Mock object to return \Magento\Framework\DataObject */
     $this->_objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\Webapi\\Rest\\Response\\Renderer\\Json')->will($this->returnValue(new \Magento\Framework\DataObject()));
     $this->setExpectedException('LogicException', 'The renderer must implement "Magento\\Framework\\Webapi\\Rest\\Response\\RendererInterface".');
     $this->_factory->get();
 }
Exemplo n.º 2
0
 /**
  * Dispatch SOAP request.
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     $path = $this->_pathProcessor->process($request->getPathInfo());
     $this->_request->setPathInfo($path);
     $this->areaList->getArea($this->_appState->getAreaCode())->load(\Magento\Framework\App\Area::PART_TRANSLATE);
     try {
         if ($this->_isWsdlRequest()) {
             $this->validateWsdlRequest();
             $responseBody = $this->_wsdlGenerator->generate($this->_request->getRequestedServices(), $this->_request->getScheme(), $this->_request->getHttpHost(), $this->_soapServer->generateUri());
             $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
             $this->_setResponseBody($responseBody);
         } else {
             if ($this->_isWsdlListRequest()) {
                 $servicesList = [];
                 foreach (array_keys($this->_wsdlGenerator->getListOfServices()) as $serviceName) {
                     $servicesList[$serviceName]['wsdl_endpoint'] = $this->_soapServer->getEndpointUri() . '?' . \Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_WSDL . '&services=' . $serviceName;
                 }
                 $renderer = $this->rendererFactory->get();
                 $this->_setResponseContentType($renderer->getMimeType());
                 $this->_setResponseBody($renderer->render($servicesList));
             } else {
                 $this->_soapServer->handle();
             }
         }
     } catch (\Exception $e) {
         $this->_prepareErrorResponse($e);
     }
     return $this->_response;
 }
Exemplo n.º 3
0
 /**
  * Initialize dependencies.
  *
  * @param \Magento\Framework\Webapi\Rest\Response\RendererFactory $rendererFactory
  * @param \Magento\Framework\Webapi\ErrorProcessor $errorProcessor
  * @param \Magento\Framework\App\State $appState
  */
 public function __construct(\Magento\Framework\Webapi\Rest\Response\RendererFactory $rendererFactory, \Magento\Framework\Webapi\ErrorProcessor $errorProcessor, \Magento\Framework\App\State $appState)
 {
     $this->_renderer = $rendererFactory->get();
     $this->_errorProcessor = $errorProcessor;
     $this->_appState = $appState;
 }