/** * Test clearing values. * * @return void */ public function testClear() { $cfg = "[a]\nb[]=1\nb[]=2\n[b]\nc=3\n"; $test = new Writer('fake.ini', $cfg); $test->clear('a', 'b[]'); // clear array $test->clear('b', 'c'); // clear single value $test->clear('z', 'z'); // clear value that does not exist $this->assertEquals("[a]\n[b]", trim($test->getContent())); }
/** * Try switching to a specific SSL configuration. * * @param array $config Setting(s) to add to [Http] section of config.ini. * @param int $try Which config index are we trying right now? * * @return void */ protected function testSslCertConfig($config, $try) { $file = ConfigLocator::getLocalConfigPath('config.ini', null, true); $writer = new ConfigWriter($file); // Reset old settings $writer->clear('Http', 'sslcapath'); $writer->clear('Http', 'sslcafile'); // Load new settings foreach ($config as $setting => $value) { $writer->set('Http', $setting, $value); } if (!$writer->save()) { throw new \Exception('Cannot write config to disk.'); } // Jump back to fix action so we can check if it worked (and attempt // the next config by incrementing the $try variable, if necessary): return $this->redirect()->toRoute('install-fixsslcerts', [], ['query' => ['try' => $try + 1]]); }