19declare(strict_types=1);
22use PHPUnit\Framework\TestCase;
28 protected function setUp(): void
30 $this->file = tempnam(sys_get_temp_dir(),
'ini_read_');
35 .
"absolute_path = \"/var/www/ilias\"\n"
36 .
"timezone = \"Europe/Zurich\"\n"
39 .
"default = \"default\"\n"
45 if (is_file($this->file)) {
53 self::assertSame([
'server',
'clients'], $repo->getSections());
59 self::assertTrue($repo->hasSection(
'server'));
60 self::assertFalse($repo->hasSection(
'missing'));
66 self::assertSame(
'/var/www/ilias', $repo->get(
'server',
'absolute_path'));
67 self::assertSame(
'Europe/Zurich', $repo->get(
'server',
'timezone'));
74 [
'absolute_path' =>
'/var/www/ilias',
'timezone' =>
'Europe/Zurich'],
75 $repo->getSection(
'server')
82 self::assertTrue($repo->has(
'clients',
'default'));
83 self::assertFalse($repo->has(
'clients',
'missing'));
84 self::assertFalse($repo->has(
'missing',
'default'));
90 $this->expectException(InvalidArgumentException::class);
91 $repo->get(
'server',
'does_not_exist');
97 $this->expectException(InvalidArgumentException::class);
98 $repo->getSection(
'does_not_exist');
104 self::assertSame([], $repo->getSections());
Read-only access to an INI file.
testMissingFileResultsInEmptyRepository()
testGetSectionReturnsAllPairs()
testGetSectionOnUnknownSectionThrows()
testGetSectionsReturnsAllSectionNamesInOrder()
testGetOnUnknownKeyThrows()
testGetReturnsTheStoredValue()