/** * @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)); }
/** * 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)); }
/** * 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'); }