当前位置: 首页>>代码示例>>PHP>>正文


PHP CakeRequest::isIndex方法代码示例

本文整理汇总了PHP中CakeRequest::isIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeRequest::isIndex方法的具体用法?PHP CakeRequest::isIndex怎么用?PHP CakeRequest::isIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CakeRequest的用法示例。


在下文中一共展示了CakeRequest::isIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testAddDetector

 /**
  * Test adding detectors and having them work.
  *
  * @return void
  */
 public function testAddDetector()
 {
     $request = new CakeRequest('some/path');
     $request->addDetector('compare', array('env' => 'TEST_VAR', 'value' => 'something'));
     $_SERVER['TEST_VAR'] = 'something';
     $this->assertTrue($request->is('compare'), 'Value match failed.');
     $_SERVER['TEST_VAR'] = 'wrong';
     $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.');
     $this->assertTrue($request->is('comparecamelcase'), 'detectors should be case insensitive');
     $this->assertTrue($request->is('COMPARECAMELCASE'), 'detectors should be case insensitive');
     $_SERVER['TEST_VAR'] = 'not foo';
     $this->assertFalse($request->is('compareCamelCase'), 'Value match failed.');
     $this->assertFalse($request->is('comparecamelcase'), 'detectors should be case insensitive');
     $this->assertFalse($request->is('COMPARECAMELCASE'), 'detectors should be case insensitive');
     $request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
     $_SERVER['TEST_VAR'] = 'banana';
     $this->assertTrue($request->isBanana());
     $_SERVER['TEST_VAR'] = 'wrong value';
     $this->assertFalse($request->isBanana());
     $request->addDetector('mobile', array('options' => array('Imagination')));
     $_SERVER['HTTP_USER_AGENT'] = 'Imagination land';
     $this->assertTrue($request->isMobile());
     $_SERVER['HTTP_USER_AGENT'] = 'iPhone 3.0';
     $this->assertTrue($request->isMobile());
     $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());
     $request->return = false;
     $this->assertFalse($request->isCallMe());
     $request->addDetector('extension', array('param' => 'ext', 'options' => array('pdf', 'png', 'txt')));
     $request->params['ext'] = 'pdf';
     $this->assertTrue($request->is('extension'));
     $request->params['ext'] = 'exe';
     $this->assertFalse($request->isExtension());
 }
开发者ID:xMyThoLoGyx,项目名称:centremedicaletp3,代码行数:48,代码来源:CakeRequestTest.php

示例2: testAddDetector

 /**
  * test adding detectors and having them work.
  *
  * @return void
  */
 public function testAddDetector()
 {
     $request = new CakeRequest('some/path');
     $request->addDetector('compare', array('env' => 'TEST_VAR', 'value' => 'something'));
     $_SERVER['TEST_VAR'] = 'something';
     $this->assertTrue($request->is('compare'), 'Value match failed.');
     $_SERVER['TEST_VAR'] = 'wrong';
     $this->assertFalse($request->is('compare'), 'Value mis-match failed.');
     $request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/'));
     $_SERVER['TEST_VAR'] = 'banana';
     $this->assertTrue($request->isBanana());
     $_SERVER['TEST_VAR'] = 'wrong value';
     $this->assertFalse($request->isBanana());
     $request->addDetector('mobile', array('options' => array('Imagination')));
     $_SERVER['HTTP_USER_AGENT'] = 'Imagination land';
     $this->assertTrue($request->isMobile());
     $_SERVER['HTTP_USER_AGENT'] = 'iPhone 3.0';
     $this->assertTrue($request->isMobile());
     $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());
     $request->return = false;
     $this->assertFalse($request->isCallMe());
 }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:34,代码来源:CakeRequestTest.php


注:本文中的CakeRequest::isIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。