v=$v;} public function isTrue(): bool { return $this->v; } public function getVariableValue(): string { return $this->v ? 'true' : 'false'; } } class FakeStringVar { private string $v; public function __construct(string $v){$this->v=$v;} public function getVariableValue(): string { return $this->v; } } class FakeBirdConfig { public $enabled; public $api_key; public $server_url; } class TestBird extends \classes\bird { public function __construct(bool $enabled, string $api_key, string $server_url) { // Do not call parent constructor to avoid DB access $cfg = new FakeBirdConfig(); $cfg->enabled = new FakeBoolVar($enabled); $cfg->api_key = new FakeStringVar($api_key); $cfg->server_url = new FakeStringVar($server_url); $this->config = $cfg; } protected function doHttpRequest(string $method, string $url, array $headers, string $body = ''): array { return ['status_code' => 200, 'body' => '{}']; } } // Positive checks $b = new TestBird(true, 'test_token_123', 'https://api.bird.com'); try { $b->requireModuleEnabled(); ok('Module enabled check passes when enabled=true'); } catch (\Exception $e) { fail('Module enabled should pass when enabled=true'); } try { $b->requireValidApiKey(); ok('API key check passes when key provided'); } catch (\Exception $e) { fail('API key should be considered valid when provided'); } try { $b->requireValidServerURL(); ok('Server URL check passes when URL provided'); } catch (\Exception $e) { fail('Server URL should be considered valid when provided'); } // Negative checks $thrown = false; try { (new TestBird(false, 'x', 'https://api.bird.com'))->requireModuleEnabled(); } catch (\Exception $e) { $thrown = true; } if ($thrown) { ok('Module enabled guard throws when disabled'); } else { fail('Module enabled guard should throw when disabled'); } $thrown = false; try { (new TestBird(true, '', 'https://api.bird.com'))->requireValidApiKey(); } catch (\Exception $e) { $thrown = true; } if ($thrown) { ok('API key guard throws when key is empty'); } else { fail('API key guard should throw when key is empty'); } $thrown = false; try { (new TestBird(true, 'x', ''))->requireValidServerURL(); } catch (\Exception $e) { $thrown = true; } if ($thrown) { ok('Server URL guard throws when URL is empty'); } else { fail('Server URL guard should throw when URL is empty'); } echo "\nBirdConfigTest completed.\n";