Exemplo n.º 1
0
 /**
  * Gets the URI of the form.
  *
  * The returned URI is not the same as the form "action" attribute.
  * This method merges the value if the method is GET to mimics
  * browser behavior.
  *
  * @return string The URI
  */
 public function getUri()
 {
     $uri = parent::getUri();
     if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) {
         $query = parse_url($uri, PHP_URL_QUERY);
         $currentParameters = array();
         if ($query) {
             parse_str($query, $currentParameters);
         }
         $queryString = http_build_query(array_merge($currentParameters, $this->getValues()), null, '&');
         $pos = strpos($uri, '?');
         $base = $pos === false ? $uri : substr($uri, 0, $pos);
         $uri = rtrim($base . '?' . $queryString, '?');
     }
     return $uri;
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getGetUriTests
  */
 public function testGetUriOnLink($url, $currentUri, $expected)
 {
     $node = $this->createNode('link', 'foo', array('href' => $url));
     $link = new Link($node, $currentUri);
     $this->assertEquals($expected, $link->getUri());
 }