Ejemplo n.º 1
0
 public function testSaveData()
 {
     $storage = new File($this->sampleWrite);
     $cfg = new Config($storage);
     $cfg->set('name', 'first');
     $contents = file_get_contents($this->sampleWrite);
     $this->assertTrue(strpos($contents, '"name":"first"') !== false);
     $cfg->push('name', 'last');
     $contents = file_get_contents($this->sampleWrite);
     $this->assertTrue(strpos($contents, '"name[1]":"last"') !== false);
 }
Ejemplo n.º 2
0
 public function testPrependPush()
 {
     $cfg = new Config([]);
     $cfg->prepend('prepend', 'value');
     // non-existing key
     $this->assertSame($cfg->get('prepend')[0], 'value');
     $cfg->prepend('prepend', 'other Value');
     $this->assertSame(count($cfg->get('prepend')), 2);
     $this->assertSame($cfg->get('prepend')[0], 'other Value');
     // push a value onto the end
     $cfg->push('prepend', 'last value');
     $this->assertSame(count($cfg->get('prepend')), 3);
     $this->assertSame($cfg->get('prepend')[0], 'other Value');
 }