Skip to content

Commit

Permalink
Passing input array by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
chdemko committed May 10, 2012
1 parent bbb8a3e commit 4dded97
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libraries/joomla/input/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class JInput implements Serializable
*
* @since 11.1
*/
public function __construct($source = null, array $options = array())
public function __construct(&$source = null, array $options = array())
{
if (isset($options['filter']))
{
Expand Down
42 changes: 31 additions & 11 deletions tests/suites/unit/joomla/input/JInputTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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)
);

Expand Down Expand Up @@ -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)
);

Expand Down Expand Up @@ -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()));
}
}

0 comments on commit 4dded97

Please sign in to comment.