makeDb(); $repo = new AppSettingsRepository($pdo); $this->assertSame('0', $repo->get('task_status_enabled')); $this->assertFalse($repo->getBool('task_status_enabled', false)); } public function testSetReturnsBeforeAndAfter(): void { $pdo = $this->makeDb(); $repo = new AppSettingsRepository($pdo); $r = $repo->set('task_status_enabled', '1'); $this->assertSame('0', $r['before']); $this->assertSame('1', $r['after']); $this->assertTrue($repo->getBool('task_status_enabled')); } public function testSetWithSameValueIsRecognisedAsNoop(): void { $pdo = $this->makeDb(); $repo = new AppSettingsRepository($pdo); $r = $repo->set('task_status_enabled', '0'); $this->assertSame('0', $r['before']); $this->assertSame('0', $r['after']); } public function testGetReturnsDefaultForUnknownKey(): void { $pdo = $this->makeDb(); $repo = new AppSettingsRepository($pdo); $this->assertNull($repo->get('does_not_exist')); $this->assertSame('fallback', $repo->get('does_not_exist', 'fallback')); $this->assertFalse($repo->getBool('does_not_exist')); $this->assertTrue($repo->getBool('does_not_exist', true)); } public function testInsertNewKeyOnFirstWrite(): void { $pdo = $this->makeDb(); $repo = new AppSettingsRepository($pdo); $r = $repo->set('new_flag', '1'); $this->assertNull($r['before']); $this->assertSame('1', $r['after']); $this->assertSame('1', $repo->get('new_flag')); } }