Beispiel #1
0
 /**
  * Tests createUri() method
  *
  * @param   array  $url      valid inputs to the createUri() method
  * @param   array  $preset   global Vars that should be merged into the URL
  * @param   string $expected expected URI string
  *
  * @dataProvider casesCreateUri
  * @testdox      createUri() generates URI combining URL and preset variables
  * @since        3.4
  */
 public function testCreateUriGeneratesUriFromUrlAndPreset($url, $preset, $expected)
 {
     $this->object->setVars($preset, false);
     $createUriMethod = new ReflectionMethod('JRouter', 'createUri');
     $createUriMethod->setAccessible(true);
     $this->assertEquals($expected, (string) $createUriMethod->invoke($this->object, $url));
 }
Beispiel #2
0
 /**
  * Tests createURI() method
  *
  * @param   array   $url         valid inputs to the createURI() method
  * @param   array   $globalVars  global Vars that should be merged into the URL
  * @param   string  $expected    expected URI string
  *
  * @dataProvider casesCreateURI
  *
  * @return void
  *
  * @since  3.4
  */
 public function testCreateURI($url, $globalVars, $expected)
 {
     $this->object->setVars($globalVars, false);
     $juri = $this->object->runCreateURI($url);
     $this->assertTrue(is_a($juri, 'JUri'));
     $this->assertEquals($juri->toString(), $expected);
 }
Beispiel #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());
 }
 /**
  * Tests the setVar method
  *
  * @param   array    $vars      An associative array with variables
  * @param   string   $var       The name of the variable
  * @param   mixed    $value     The value of the variable
  * @param   boolean  $create    If True, the variable will be created if it doesn't exist yet
  * @param   string   $expected  Expected return value
  *
  * @return  void
  *
  * @dataProvider  casesSetVar
  * @since         3.1
  */
 public function testSetVar($vars, $var, $value, $create, $expected)
 {
     $this->object->setVars($vars, false);
     $this->object->setVar($var, $value, $create);
     $this->assertEquals($this->object->getVar($var), $expected, __METHOD__ . ':' . __LINE__ . ': value is not expected');
 }