示例#1
0
 /**
  * Test get method with wrong API type.
  */
 public function testGetWithWrongApiType()
 {
     $wrongApiType = 'Wrong SOAP';
     /**Mock front controller determine api method to return wrong api type */
     $this->_apiFrontController->expects($this->once())->method('determineApiType')->will($this->returnValue($wrongApiType));
     $this->setExpectedException('LogicException', sprintf('There is no corresponding response class for the "%s" API type.', $wrongApiType));
     $this->_factory->get();
 }
示例#2
0
 /**
  * Create response object.
  *
  * Use current API type to define proper response class.
  *
  * @return Mage_Webapi_Controller_Response
  * @throws LogicException If there is no corresponding response class for current API type.
  */
 public function get()
 {
     $apiType = $this->_apiFrontController->determineApiType();
     if (!isset($this->_apiResponseMap[$apiType])) {
         throw new LogicException(sprintf('There is no corresponding response class for the "%s" API type.', $apiType));
     }
     $requestClass = $this->_apiResponseMap[$apiType];
     return $this->_objectManager->get($requestClass);
 }
示例#3
0
 public function testDeterminateApiTypeApiIsSet()
 {
     $this->_createMockForApiRouteAndFactory(array('api_type' => Mage_Webapi_Controller_Front::API_TYPE_SOAP));
     /** Assert createRoute method will be executed only once */
     $this->_routeFactoryMock->expects($this->once())->method('createRoute');
     /** The first method call will set apiType property using createRoute method. */
     $this->_frontControllerMock->determineApiType();
     /** The second method call should use set apiType and should not trigger createRoute method. */
     $this->_frontControllerMock->determineApiType();
 }