assertInstanceOf(Config::class, $config); } public function testConstructDev(): void { $config = new Config(true); $this->assertInstanceOf(Config::class, $config); $this->assertTrue($config->getIsDevelopmentServer()); } public function testConstructDevFromTruthyValue(): void { $config = new Config("yes"); $this->assertInstanceOf(Config::class, $config); $this->assertTrue($config->getIsDevelopmentServer()); } public function testReadFromIniFile(): void { $data = "hostname=fabricate.dev"; file_put_contents('test.ini', $data); $config = new Config(); $config->readFromIniFile('test.ini'); $this->assertSame('fabricate.dev', $config->hostname); @unlink('test.ini'); } public function testReadFromIniNonFile(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Cannot read config file'); $config = new Config(); $config->readFromIniFile('nonfile.ini'); } public function testReadFromIniAllPossibleKeys(): void { $data = <<readFromIniFile('test.ini'); $this->assertSame('1.1.1.1', $config->host); $this->assertSame('1988', $config->port); $this->assertSame('beatles.org', $config->hostname); $this->assertSame('1212', $config->tls_certfile); $this->assertSame('3434', $config->tls_keyfile); $this->assertSame('strawberry', $config->keypassphrase); $this->assertSame('xyz.log', $config->log_file); $this->assertSame('cherry', $config->log_level); $this->assertSame('blueberry', $config->root_dir); $this->assertSame('led.gmi', $config->index_file); $this->assertSame('0', $config->enable_directory_index); @unlink('test.ini'); } public function testReadFromIniWithInvalidKey(): void { $data = <<readFromIniFile('test.ini'); $this->assertFalse(property_exists($config, 'invalid_key')); @unlink('test.ini'); } }