Exemplo n.º 1
0
 /**
  * Tests the parseSefRoute method
  *
  * @param   string   $url              An associative array with variables
  * @param   integer  $menubool         JROUTER_MODE_RAW or JROUTER_MODE_SEF
  * @param   array    $appConfig        An associative array with app config vars
  * @param   array    $expected         An associative array with $_SERVER vars
  * @param   array    $expectedGlobals  An associative array with $_SERVER vars
  * @param   boolean  $activeMenu       Flag if the item is the active menu
  *
  * @return  void
  *
  * @dataProvider  casesParseSefRoute
  * @since         3.4
  */
 public function testParseSefRoute($url, $menubool, $appConfig, $expected, $expectedGlobals, $activeMenu = false)
 {
     $uri = new JUri($url);
     $app = $this->object->getApp();
     if (isset($expected['Itemid'])) {
         $app->input->set('Itemid', $expected['Itemid']);
     }
     if (isset($appConfig['languagefilter'])) {
         $app->expects($this->any())->method('getLanguageFilter')->will($this->returnValue(true));
         unset($appConfig['languagefilter']);
     }
     $app->expects($this->any())->method('get')->will($this->returnValueMap($appConfig));
     $this->object->setApp($app);
     if ($menubool) {
         $menu = TestMockMenu::create($this, false, $activeMenu);
         $menu->expects($this->any())->method('getDefault')->will($this->returnValue(null));
         $this->object->setMenu($menu);
     } else {
         $menu = TestMockMenu::create($this, true, $activeMenu);
         $this->object->setMenu($menu);
     }
     // The method should return an array of variables
     $vars = $this->object->runParseSefRoute($uri);
     $this->assertEquals($expected, $vars);
     $this->assertEquals($expectedGlobals, $this->object->getVars(), 'global vars');
 }
Exemplo n.º 2
0
 /**
  * @see     https://github.com/joomla-projects/joomla-pythagoras/issues/3
  * @since   3.4
  */
 public function testMultipleVariablesCanBeAddedAtOnceAndOptionallyReplaceExistingVariables()
 {
     $this->assertEquals(array(), $this->object->getVars());
     $this->object->setVars(array('var1' => 'value1'));
     $this->assertEquals(array('var1' => 'value1'), $this->object->getVars());
     $this->object->setVars(array('var2' => 'value2'));
     $this->assertEquals(array('var1' => 'value1', 'var2' => 'value2'), $this->object->getVars());
     $this->object->setVars(array('var3' => 'value3'), false);
     $this->assertEquals(array('var3' => 'value3'), $this->object->getVars());
     $this->object->setVars(array(), false);
     $this->assertEquals(array(), $this->object->getVars());
 }
Exemplo n.º 3
0
 /**
  * Tests the getVars() method
  *
  * @return void
  *
  * @since  3.4
  */
 public function testGetVars()
 {
     $this->assertEquals($this->object->getVars(), array());
     $this->object->setVars(array('var1' => 'value1'));
     $this->assertEquals($this->object->getVars(), array('var1' => 'value1'));
     $this->object->setVars(array('var2' => 'value2'));
     $this->assertEquals($this->object->getVars(), array('var1' => 'value1', 'var2' => 'value2'));
     $this->object->setVars(array('var3' => 'value3'), false);
     $this->assertEquals($this->object->getVars(), array('var3' => 'value3'));
     $this->object->setVars(array(), false);
     $this->assertEquals($this->object->getVars(), array());
 }