示例#1
0
 /**
  * @param CM_Frontend_ViewResponse $viewResponse
  * @return string
  */
 public function fetchViewResponse(CM_Frontend_ViewResponse $viewResponse)
 {
     return $this->fetchViewTemplate($viewResponse->getView(), $viewResponse->getTemplateName(), $viewResponse->getData());
 }
示例#2
0
 /**
  * @param CM_View_Abstract              $view
  * @param string                        $methodName
  * @param array|null                    $params
  * @param CM_Frontend_ViewResponse|null $viewResponse
  * @param CM_Frontend_ViewResponse|null $componentResponse
  * @throws CM_Exception_Invalid
  * @return CM_Http_Request_Post|\Mocka\AbstractClassTrait
  */
 public function createRequestAjax(CM_View_Abstract $view, $methodName, array $params = null, CM_Frontend_ViewResponse $viewResponse = null, CM_Frontend_ViewResponse $componentResponse = null)
 {
     if (null === $viewResponse) {
         $viewResponse = new CM_Frontend_ViewResponse($view);
     } else {
         if ($viewResponse->getView() !== $view) {
             throw new CM_Exception_Invalid("View doesn't match value from scopeView");
         }
     }
     if (null === $componentResponse) {
         if ($viewResponse->getView() instanceof CM_Component_Abstract) {
             $componentResponse = $viewResponse;
         } else {
             /** @var CM_Component_Abstract $component */
             $component = $this->mockClass('CM_Component_Abstract')->newInstance();
             $componentResponse = new CM_Frontend_ViewResponse($component);
         }
     } else {
         if (!$componentResponse->getView() instanceof CM_Component_Abstract) {
             throw new CM_Exception_Invalid("ScopeComponent's view is not a component");
         }
     }
     $query = array('method' => (string) $methodName, 'params' => (array) $params);
     return $this->createRequest('/ajax/null', $query, null, $viewResponse, $componentResponse);
 }
示例#3
0
 /**
  * @param CM_FormAction_Abstract        $action
  * @param array|null                    $data
  * @param CM_Frontend_ViewResponse|null $scopeView
  * @param CM_Frontend_ViewResponse|null $scopeComponent
  * @throws CM_Exception_Invalid
  * @return CM_Http_Request_Post|\Mocka\AbstractClassTrait
  */
 public function createRequestFormAction(CM_FormAction_Abstract $action, array $data = null, CM_Frontend_ViewResponse $scopeView = null, CM_Frontend_ViewResponse $scopeComponent = null)
 {
     $actionName = $action->getName();
     $form = $action->getForm();
     if (null === $scopeView) {
         $scopeView = new CM_Frontend_ViewResponse($form);
     }
     if ($scopeView->getView() !== $form) {
         throw new CM_Exception_Invalid('Action\'s form and ViewResponse\'s view must match');
     }
     if (null === $scopeComponent) {
         $component = $this->mockClass('CM_Component_Abstract')->newInstance();
         $scopeComponent = new CM_Frontend_ViewResponse($component);
     }
     $query = array('data' => (array) $data, 'actionName' => $actionName);
     return $this->createRequest('/form/null', $query, null, $scopeView, $scopeComponent);
 }