newConfig() public method

the returned object has already been added to our list, and does not need to be added manually
public newConfig ( string $name ) : object
$name string the name of this new config entry
return object
Ejemplo n.º 1
0
 /**
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::__construct
  * @covers DataSift\Storyplayer\ConfigLib\ConfigList::addHardCodedList
  */
 public function testCanAddEntriesFromAHardCodedList()
 {
     // ----------------------------------------------------------------
     // setup your test
     $obj = new ConfigList("DataSift\\Storyplayer\\ConfigLib\\WrappedConfig", __DIR__ . '/ConfigListTestData1');
     $hardCodedList = new HardCodedList('DataSift\\Storyplayer\\ConfigLib\\WrappedConfig');
     $expected1 = $hardCodedList->newConfig('hard-coded-config-1');
     $expected1->getConfig()->name = 'config-1';
     $expected2 = $hardCodedList->newConfig('hard-coded-config-2');
     $expected2->getConfig()->name = 'config-2';
     // ----------------------------------------------------------------
     // perform the change
     $obj->addHardCodedList($hardCodedList);
     // ----------------------------------------------------------------
     // test the results
     $this->assertTrue($obj->hasEntry('hard-coded-config-1'));
     $this->assertSame($expected1, $obj->getEntry('hard-coded-config-1'));
     $this->assertTrue($obj->hasEntry('hard-coded-config-2'));
     $this->assertSame($expected2, $obj->getEntry('hard-coded-config-2'));
 }
Ejemplo n.º 2
0
 /**
  * @covers DataSift\Storyplayer\ConfigLib\HardCodedList::__construct
  * @covers DataSift\Storyplayer\ConfigLib\HardCodedList::newConfig
  * @covers DataSift\Storyplayer\ConfigLib\HardCodedList::addConfig
  * @covers DataSift\Storyplayer\ConfigLib\HardCodedList::getConfigs
  */
 public function testNewConfigsAreAutoAddedToTheList()
 {
     // ----------------------------------------------------------------
     // setup the test
     $expectedName = 'test-config';
     $obj = new HardCodedList('DataSift\\Storyplayer\\ConfigLib\\WrappedConfig');
     // ----------------------------------------------------------------
     // perform the change
     $newConfig = $obj->newConfig($expectedName);
     // ----------------------------------------------------------------
     // test the results
     $configs = $obj->getConfigs();
     $this->assertTrue(isset($configs[$expectedName]));
     $this->assertSame($configs[$expectedName], $newConfig);
 }