Implement $request->is('requested');

Add tests and new detector type for request parameters
Fixes #1995
This commit is contained in:
mark_story 2011-10-20 21:11:42 -04:00
parent 53bc963315
commit eb17653965
2 changed files with 46 additions and 1 deletions

View file

@ -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
*