Exemplo n.º 1
0
 /**
  * Test the Joomla\Input\Cli::get method.
  *
  * @return  void
  *
  * @covers  Joomla\Input\Cli::get
  * @since   1.0
  */
 public function testParseShortArguments()
 {
     $_SERVER['argv'] = array('/dev/null', '-ab', '-c', '-e', 'f', 'foobar', 'ghijk');
     $instance = new Cli(null, array('filter' => new FilterInputMock()));
     $this->assertThat($instance->get('a'), $this->identicalTo(true), 'Line: ' . __LINE__ . '.');
     $this->assertThat($instance->get('b'), $this->identicalTo(true), 'Line: ' . __LINE__ . '.');
     $this->assertThat($instance->get('c'), $this->identicalTo(true), 'Line: ' . __LINE__ . '.');
     $this->assertThat($instance->get('e'), $this->identicalTo('f'), 'Line: ' . __LINE__ . '.');
     $this->assertThat($instance->args, $this->equalTo(array('foobar', 'ghijk')), 'Line: ' . __LINE__ . '.');
 }
Exemplo n.º 2
0
 /**
  * Test the Joomla\Input\Input::unserialize method.
  *
  * @return  void
  *
  * @covers  Joomla\Input\Cli::unserialize
  * @since   1.1.4
  */
 public function testUnserialize()
 {
     $serialized = 'a:5:{i:0;s:9:"/dev/null";i:1;a:1:{s:3:"foo";s:3:"bar";}i:2;a:1:{s:6:"filter";s:3:"raw";}i:3;s:4:"data";i:4;a:1:{s:7:"request";s:4:"keep";}}';
     $instance = new Cli(null, array('filter' => new FilterInputMock()));
     $instance->unserialize($serialized);
     $this->assertEquals('/dev/null', TestHelper::getValue($instance, 'executable'));
     $this->assertEquals(array('foo' => 'bar'), TestHelper::getValue($instance, 'args'));
     $this->assertEquals(array('request' => 'keep'), TestHelper::getValue($instance, 'inputs'));
     $this->assertEquals(array('filter' => 'raw'), TestHelper::getValue($instance, 'options'));
     $this->assertEquals('data', TestHelper::getValue($instance, 'data'));
 }