mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 12:02:41 +00:00
Implement $request->is('requested');
Add tests and new detector type for request parameters Fixes #1995
This commit is contained in:
parent
53bc963315
commit
eb17653965
2 changed files with 46 additions and 1 deletions
|
@ -744,6 +744,13 @@ class CakeRequestTest extends CakeTestCase {
|
|||
|
||||
$request->addDetector('callme', array('env' => 'TEST_VAR', 'callback' => array($this, '_detectCallback')));
|
||||
|
||||
$request->addDetector('index', array('param' => 'action', 'value' => 'index'));
|
||||
$request->params['action'] = 'index';
|
||||
$this->assertTrue($request->isIndex());
|
||||
|
||||
$request->params['action'] = 'add';
|
||||
$this->assertFalse($request->isIndex());
|
||||
|
||||
$request->return = true;
|
||||
$this->assertTrue($request->isCallMe());
|
||||
|
||||
|
@ -1565,6 +1572,32 @@ XML;
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test is('requested') and isRequested()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIsRequested() {
|
||||
$request = new CakeRequest('/posts/index');
|
||||
$request->addParams(array(
|
||||
'controller' => 'posts',
|
||||
'action' => 'index',
|
||||
'plugin' => null,
|
||||
'requested' => 1
|
||||
));
|
||||
$this->assertTrue($request->is('requested'));
|
||||
$this->assertTrue($request->isRequested());
|
||||
|
||||
$request = new CakeRequest('/posts/index');
|
||||
$request->addParams(array(
|
||||
'controller' => 'posts',
|
||||
'action' => 'index',
|
||||
'plugin' => null,
|
||||
));
|
||||
$this->assertFalse($request->is('requested'));
|
||||
$this->assertFalse($request->isRequested());
|
||||
}
|
||||
|
||||
/**
|
||||
* loadEnvironment method
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue