本文整理汇总了PHP中JRouter::attachParseRule方法的典型用法代码示例。如果您正苦于以下问题:PHP JRouter::attachParseRule方法的具体用法?PHP JRouter::attachParseRule怎么用?PHP JRouter::attachParseRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRouter
的用法示例。
在下文中一共展示了JRouter::attachParseRule方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFirstParseRuleTakesPrecedence
/**
* @param array $preset Initial router variables
* @param array $rules Callback to execute
* @param string $stage Stage to process
* @param string $expected Expected return value
*
* @dataProvider casesParseRulesForPrecedence
* @since 3.4
*/
public function testFirstParseRuleTakesPrecedence($preset, $rules, $stage, $expected)
{
$this->object->setVars($preset, false);
foreach ($rules as $rule) {
$this->object->attachParseRule($rule, $stage);
}
$uri = $this->getMock('JUri');
$this->assertEquals($expected, $this->object->parse($uri));
}
示例2: testDetachRule
/**
* Tests the detachRule() method
*
* @return void
*
* @since 4.0
* @covers JRouter::detachRule
*/
public function testDetachRule()
{
$rule = function () {
};
$this->object->attachParseRule($rule);
$rules = $this->object->getRules();
$this->assertEquals(array($rule), $rules['parse']);
$this->assertTrue($this->object->detachRule('parse', $rule));
$rules = $this->object->getRules();
$this->assertEquals(array(), $rules['parse']);
$this->assertFalse($this->object->detachRule('parse', $rule));
}
示例3: testAttachParseRuleException
/**
* Tests the attachParseRule() method throwing a proper exception
*
* @return void
*
* @since 3.4
* @expectedException InvalidArgumentException
*/
public function testAttachParseRuleException()
{
$callback = array(function (&$router, &$uri) {
});
$this->object->attachParseRule($callback, 'wrongStage');
}