コード例 #1
0
ファイル: GetOrderTest.php プロジェクト: hschletz/braintacle
 /**
  * Invoke plugin and test various combinations of request and plugin parameters
  */
 public function testInvoke()
 {
     $plugin = $this->_getPlugin(true);
     $request = $this->_controller->getRequest();
     $parameters = new \Zend\Stdlib\Parameters();
     // Defaults only
     $parameters->fromArray(array());
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Default', 'direction' => 'asc'), $plugin('Default'));
     // Explicit order in request
     $parameters->fromArray(array('order' => 'Order'));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Order', 'direction' => 'asc'), $plugin('Default'));
     // Invalid (empty) order in request
     $parameters->fromArray(array('order' => ''));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Default', 'direction' => 'asc'), $plugin('Default'));
     // Explicit order and direction in request
     $parameters->fromArray(array('order' => 'Order', 'direction' => 'asc'));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Order', 'direction' => 'asc'), $plugin('Default'));
     // Explicit order and non-default direction in request
     $parameters->fromArray(array('order' => 'Order', 'direction' => 'desc'));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Order', 'direction' => 'desc'), $plugin('Default'));
     // Explicit order and invalid direction in request
     $parameters->fromArray(array('order' => 'Order', 'direction' => 'invalid'));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Order', 'direction' => 'asc'), $plugin('Default'));
     // Explicit order and invalid direction in request, nonstandard default direction
     $parameters->fromArray(array('order' => 'Order', 'direction' => 'invalid'));
     $request->setQuery($parameters);
     $this->assertEquals(array('order' => 'Order', 'direction' => 'desc'), $plugin('Default', 'desc'));
 }
 public function createAjaxRequestWithSpecificPostData($postData)
 {
     $request = new Request();
     $request->getHeaders()->addHeaders(['X_REQUESTED_WITH' => 'XMLHttpRequest']);
     $parameters = new \Zend\Stdlib\Parameters();
     $parameters->fromArray($postData);
     $request->setPost($parameters);
     return $request;
 }
コード例 #3
0
ファイル: Attribute.php プロジェクト: smile-sa/elasticsuite
 /**
  * Create the URL used to apply the filter from a existing URL.
  *
  * @param array $qsParams Query string params.
  *
  * @return NULL|string
  */
 private function rewriteBaseUrl($qsParams)
 {
     $url = null;
     if ($this->getBaseUrl()) {
         $baseUrlParts = explode('?', $this->getBaseUrl());
         $qsParser = new \Zend\Stdlib\Parameters();
         $qsParser->fromArray($qsParams);
         if (count($baseUrlParts) > 1) {
             $qsParser->fromString($baseUrlParts[1]);
             $qsParams = array_merge($qsParser->toArray(), $qsParams);
             $qsParser->fromArray($qsParams);
         }
         $baseUrlParts[1] = $qsParser->toString();
         $url = implode('?', $baseUrlParts);
     }
     return $url;
 }