create([ 'name' => 'OpenAI API Key', 'api_key' => 'sk-test-value-that-is-long-enough', 'is_active' => true, ]); $raw = $setting->getRawOriginal('api_key'); $this->assertNotSame('sk-test-value-that-is-long-enough', $raw); $this->assertSame('sk-test-value-that-is-long-enough', $setting->api_key); } /** * It resolves the latest active API key setting. */ public function test_it_resolves_latest_active_api_key_setting(): void { ChatGptApiSetting::query()->create([ 'name' => 'Inactive', 'api_key' => 'sk-inactive-value-that-is-long-enough', 'is_active' => false, ]); $active = ChatGptApiSetting::query()->create([ 'name' => 'Active', 'api_key' => 'sk-active-value-that-is-long-enough', 'is_active' => true, ]); $this->assertTrue($active->is(ChatGptApiSetting::active())); } }