mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
commit
6599422a7a
2 changed files with 6 additions and 0 deletions
|
@ -516,6 +516,7 @@ class CakeRequest implements ArrayAccess {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function addDetector($name, $options) {
|
public function addDetector($name, $options) {
|
||||||
|
$name = strtolower($name);
|
||||||
if (isset($this->_detectors[$name]) && isset($options['options'])) {
|
if (isset($this->_detectors[$name]) && isset($options['options'])) {
|
||||||
$options = Set::merge($this->_detectors[$name], $options);
|
$options = Set::merge($this->_detectors[$name], $options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -793,6 +793,11 @@ class CakeRequestTest extends CakeTestCase {
|
||||||
|
|
||||||
$_SERVER['TEST_VAR'] = 'wrong';
|
$_SERVER['TEST_VAR'] = 'wrong';
|
||||||
$this->assertFalse($request->is('compare'), 'Value mis-match failed.');
|
$this->assertFalse($request->is('compare'), 'Value mis-match failed.');
|
||||||
|
|
||||||
|
$request->addDetector('compareCamelCase', array('env' => 'TEST_VAR', 'value' => 'foo'));
|
||||||
|
|
||||||
|
$_SERVER['TEST_VAR'] = 'foo';
|
||||||
|
$this->assertTrue($request->is('compareCamelCase'), 'Value match failed.');
|
||||||
|
|
||||||
$request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
|
$request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
|
||||||
$_SERVER['TEST_VAR'] = 'banana';
|
$_SERVER['TEST_VAR'] = 'banana';
|
||||||
|
|
Loading…
Add table
Reference in a new issue