Skip to content

Commit

Permalink
addition setRawParam method #24
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouf committed Dec 30, 2015
1 parent f037e01 commit fc0cc7a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/GoogleUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function searchTerm($search){
* @param string $value value of the param
* @return \GoogleUrl
*/
private function setParam($name,$value){
public function setParam($name,$value){
if(null === $value){
if($this->googleParams[$name]){
unset($this->googleParams[$name]);
Expand All @@ -211,12 +211,16 @@ private function setParam($name,$value){
return $this;
}

public function setRawParam($name, $value){
$this->googleParams[$name] = urldecode($value);
}

/**
* get a param by its name
* @param string $name the param to get
* @return string
*/
private function param($name){
public function param($name){
return $this->googleParams[$name];
}

Expand All @@ -226,7 +230,7 @@ private function param($name){
* @param string $name the param to get
* @return string
*/
private function hasParam($name){
public function hasParam($name){
return isset($this->googleParams[$name]);
}

Expand Down
23 changes: 23 additions & 0 deletions tests/CoreTest/UrlTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


class UrlTest extends PHPUnit_Framework_TestCase{



public function testUrlGeneration(){

$googleUrl=new \GoogleUrl();

$googleUrl->setLang('fr')->setNumberResults(10)->searchTerm("simpsons");

$this->assertEquals("https://www.google.fr/search?q=simpsons&start=0&num=10&complete=0&pws=0&hl=fr&lr=lang_fr", $googleUrl->__toString());

$googleUrl->setRawParam("uule", "w+CAIQICIJTmV3IERlbGhp");


$this->assertEquals("https://www.google.fr/search?q=simpsons&start=0&num=10&complete=0&pws=0&hl=fr&lr=lang_fr&uule=w+CAIQICIJTmV3IERlbGhp", $googleUrl->__toString());

}

}

0 comments on commit fc0cc7a

Please sign in to comment.