Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1201 from chdemko/input

Passing input array by reference
  • Loading branch information...
commit 917d1600c67db94b24a04f90e2e5db968e1b8974 2 parents 17e17d1 + cfc4750
@LouisLandry LouisLandry authored
View
4 libraries/joomla/input/input.php
@@ -68,12 +68,12 @@ class JInput implements Serializable
/**
* Constructor.
*
- * @param array $source Source data (Optional, default is $_REQUEST)
+ * @param array &$source Source data (Optional, default is $_REQUEST)
* @param array $options Array of configuration parameters (Optional)
*
* @since 11.1
*/
- public function __construct($source = null, array $options = array())
+ public function __construct(&$source = null, array $options = array())
{
if (isset($options['filter']))
{
View
42 tests/suites/unit/joomla/input/JInputTest.php
@@ -58,6 +58,23 @@ public function test__call()
*/
public function test__get()
{
+ $_POST['foo'] = 'bar';
+
+ // Test the get method.
+ $this->assertThat(
+ $this->class->post->get('foo'),
+ $this->equalTo('bar'),
+ 'Line: '.__LINE__.'.'
+ );
+
+ // Test the set method.
+ $this->class->post->set('foo', 'notbar');
+ $this->assertThat(
+ $_POST['foo'],
+ $this->equalTo('notbar'),
+ 'Line: '.__LINE__.'.'
+ );
+
$this->markTestIncomplete();
}
@@ -155,12 +172,13 @@ public function testGetArray()
{
$filterMock = new JFilterInputMockTracker();
+ $array = array(
+ 'var1' => 'value1',
+ 'var2' => 34,
+ 'var3' => array('test')
+ );
$input = new JInput(
- array(
- 'var1' => 'value1',
- 'var2' => 34,
- 'var3' => array('test')
- ),
+ $array,
array('filter' => $filterMock)
);
@@ -202,12 +220,13 @@ public function testGetArrayNested()
{
$filterMock = new JFilterInputMockTracker();
+ $array = array(
+ 'var2' => 34,
+ 'var3' => array('var2' => 'test'),
+ 'var4' => array('var1' => array('var2' => 'test'))
+ );
$input = new JInput(
- array(
- 'var2' => 34,
- 'var3' => array('var2' => 'test'),
- 'var4' => array('var1' => array('var2' => 'test'))
- ),
+ $array,
array('filter' => $filterMock)
);
@@ -343,6 +362,7 @@ protected function setUp()
include_once __DIR__ . '/stubs/JFilterInputMock.php';
include_once __DIR__ . '/stubs/JFilterInputMockTracker.php';
- $this->class = new JInputInspector(null, array('filter' => new JFilterInputMock()));
+ $array = null;
+ $this->class = new JInputInspector($array, array('filter' => new JFilterInputMock()));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.