1, 'option2' => 'value 2', ); $this->assertEquals($configTest->getOptions(), $defaultOptions); } public function testConstructorWithObject() { $configTest = new ConfigTest(new myConfigObject); // the default options should be merged with the constructor values, // overwriting any default values. $expectedOptions = array( 'option1' => 1, 'option2' => 'newvalue2', 'option3' => 3, ); $this->assertEquals($expectedOptions, $configTest->getOptions()); } public function testConstructorWithArrayConfig() { $configTest = new ConfigTest( array('option2' => 'newvalue2', 'option3' => 3) ); // the default options should be merged with the constructor values, // overwriting any default values. $expectedOptions = array( 'option1' => 1, 'option2' => 'newvalue2', 'option3' => 3, ); $this->assertEquals($expectedOptions, $configTest->getOptions()); } public function testConstructorWithInvalidConfig() { $this->setExpectedException('Solarium_Exception'); new Solarium_Client('invalid'); } public function testGetOption() { $configTest = new ConfigTest; $this->assertEquals(1, $configTest->getOption('option1')); } public function testGetOptionWIthInvalidName() { $configTest = new ConfigTest(); $this->assertEquals(null, $configTest->getOption('invalidoptionname')); } public function testInitialisation() { $this->setExpectedException('Solarium_Exception'); new ConfigTestInit; } public function testSetOptions() { $configTest = new ConfigTest(); $configTest->setOptions(array('option2' => 2, 'option3' => 3)); $this->assertEquals( array('option1' => 1, 'option2' => 2, 'option3' => 3), $configTest->getOptions() ); } public function testSetOptionsWithOverride() { $configTest = new ConfigTest(); $configTest->setOptions(array('option2' => 2, 'option3' => 3), true); $this->assertEquals( array('option2' => 2, 'option3' => 3), $configTest->getOptions() ); } } class ConfigTest extends Solarium_Configurable { protected $_options = array( 'option1' => 1, 'option2' => 'value 2', ); } class ConfigTestInit extends ConfigTest { protected function _init() { throw new Solarium_Exception('test init'); } } class myConfigObject { public function toArray() { return array('option2' => 'newvalue2', 'option3' => 3); } }