getOption($optionName, $defaultValue); $this->assertEquals($expected, $result, 'Returned option value must be as expected.'); } /** * @param array $options * @param string $optionName, * @param mixed $expected * * @dataProvider providerTestGetOptionWithoutDefault */ public function testGetOptionWithoutDefault(array $options, $optionName, $expected) { $configurable = new ConfigurableImplementation($options); $result = $configurable->getOption($optionName); $this->assertEquals($expected, $result, 'Returned option value must be as expected.'); } /** * Data provider for testGetOptionWithDefault * * @return array */ public function providerTestGetOptionWithDefault() { return [ 'Option is not set' => [ 'options' => [], 'optionName' => 'TEST_OPTION', 'defaultValue' => 'DEFAULT', 'expected' => 'DEFAULT' ], 'Option is empty' => [ 'options' => [ 'TEST_OPTION' => '' ], 'optionName' => 'TEST_OPTION', 'defaultValue' => 'DEFAULT', 'expected' => '' ], 'Option is set' => [ 'options' => [ 'TEST_OPTION' => 'TEST_VALUE' ], 'optionName' => 'TEST_OPTION', 'defaultValue' => 'DEFAULT', 'expected' => 'TEST_VALUE' ], ]; } /** * Data provider for testGetOptionWithoutDefault * * @return array */ public function providerTestGetOptionWithoutDefault() { return [ 'Option is not set' => [ 'options' => [], 'optionName' => 'TEST_OPTION', 'expected' => null ], 'Option is empty' => [ 'options' => [ 'TEST_OPTION' => '' ], 'optionName' => 'TEST_OPTION', 'expected' => '' ], 'Option is set' => [ 'options' => [ 'TEST_OPTION' => 'TEST_VALUE' ], 'optionName' => 'TEST_OPTION', 'expected' => 'TEST_VALUE' ], ]; } } /** * Configurable class implementation for test. */ class ConfigurableImplementation extends Configurable {}