public function addEntry($name, $config) { // make sure $config is the right type $classname = $this->getWrappedConfigClassname(); if (!$config instanceof $classname) { throw new E4xx_IncompatibleConfigClass($classname, get_class($config)); } // if we get here, all is good $this->list[$name] = $config; // keep the configs sorted ksort($this->list); }
/** * @covers DataSift\Storyplayer\ConfigLib\ConfigList::__construct * @covers DataSift\Storyplayer\ConfigLib\ConfigList::addEntry * @expectedException DataSift\Storyplayer\ConfigLib\E4xx_IncompatibleConfigClass */ public function testManuallyAddedConfigsMustBeCompatibleType() { // ---------------------------------------------------------------- // setup your test $obj = new ConfigList("DataSift\\Storyplayer\\ConfigLib\\StoryplayerConfig", __DIR__ . '/ConfigListTestData1'); $obj->findConfigs(); $expectedName = 'injected-1'; $expectedConfig = new WrappedConfig(); // ---------------------------------------------------------------- // perform the change $obj->addEntry($expectedName, $expectedConfig); }