mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
parent
e5c8a446d6
commit
9c5ad71abc
2 changed files with 31 additions and 0 deletions
|
@ -413,6 +413,17 @@ class CakeRequest implements ArrayAccess {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic isset method allows isset/empty checks
|
||||
* on routing parameters.
|
||||
*
|
||||
* @param string $name The property being accessed.
|
||||
* @return bool Existence
|
||||
*/
|
||||
public function __isset($name) {
|
||||
return isset($this->params[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a Request is a certain type. Uses the built in detection rules
|
||||
* as well as additional rules defined with CakeRequest::addDetector(). Any detector can be called
|
||||
|
|
|
@ -682,6 +682,26 @@ class CakeRequestTest extends CakeTestCase {
|
|||
$this->assertIdentical($request->banana, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test isset()/empty() with overloaded properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function test__isset() {
|
||||
$request = new CakeRequest('some/path');
|
||||
$request->params = array(
|
||||
'controller' => 'posts',
|
||||
'action' => 'view',
|
||||
'plugin' => 'blogs',
|
||||
'named' => array()
|
||||
);
|
||||
|
||||
$this->assertTrue(isset($request->controller));
|
||||
$this->assertFalse(isset($request->notthere));
|
||||
$this->assertFalse(empty($request->controller));
|
||||
$this->assertTrue(empty($request->named));
|
||||
}
|
||||
|
||||
/**
|
||||
* test the array access implementation
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue