mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
adding query() for CakeRequest
This commit is contained in:
parent
144761c0b2
commit
e8cfac0eec
2 changed files with 28 additions and 0 deletions
|
@ -758,6 +758,16 @@ class CakeRequest implements ArrayAccess {
|
|||
return $accept;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a read accessor for `$this->query`. Allows you
|
||||
* to use a syntax similar to `CakeSession` for reading url query data.
|
||||
*
|
||||
* @return mixed The value being read
|
||||
*/
|
||||
public function query($name) {
|
||||
return Hash::get($this->query, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a read/write accessor for `$this->data`. Allows you
|
||||
* to use a syntax similar to `CakeSession` for reading post data.
|
||||
|
|
|
@ -1678,6 +1678,24 @@ class CakeRequestTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test the query() method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQuery() {
|
||||
$_GET = array();
|
||||
$_GET['foo'] = 'bar';
|
||||
|
||||
$request = new CakeRequest();
|
||||
|
||||
$result = $request->query('foo');
|
||||
$this->assertEquals('bar', $result);
|
||||
|
||||
$result = $request->query('imaginary');
|
||||
$this->assertNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test the data() method reading
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue