Skip to content

Commit

Permalink
Unit test for unsetting null password/username options
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed May 19, 2014
1 parent 6a285e6 commit 6d4ea34
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,41 @@ public function provideNormalizeOptions()

return $cases;
}

public function testPasswordAndUsernameShouldBeUnsetIfNull()
{
$config = array(
'connections' => array(
'conn1' => array(
'server' => 'mongodb://localhost',
'options' => array(
'username' => null,
'password' => 'bar',
),
),
'conn2' => array(
'server' => 'mongodb://localhost',
'options' => array(
'username' => 'foo',
'password' => null,
),
),
'conn3' => array(
'server' => 'mongodb://localhost',
'options' => array(
'username' => null,
'password' => null,
),
),
),
);

$processor = new Processor();
$configuration = new Configuration(false);
$options = $processor->processConfiguration($configuration, array($config));

$this->assertEquals(array('password' => 'bar'), $options['connections']['conn1']['options']);
$this->assertEquals(array('username' => 'foo'), $options['connections']['conn2']['options']);
$this->assertEquals(array(), $options['connections']['conn3']['options']);
}
}

0 comments on commit 6d4ea34

Please sign in to comment.