Add unit test coverage for textToImage() method
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3574786. --> Reported by: [jibla](https://www.drupal.org/user/1013184) >>> <p>[Tracker]<br> <strong>Update Summary: </strong>[One-line status update for stakeholders]<br> <strong>Check-in Date: </strong>MM/DD/YYYY<br> <strong>Additional Collaborators: </strong><br> <em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br> [/Tracker]</p> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Issue <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/gemini_provider/-/work_items/3572953" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/gemini_provider/-/work_items/3572953</a></span> added text-to-image support via <code>TextToImageInterface</code>. The implementation works correctly (verified via live API testing and the AI API Explorer UI), but the <code>textToImage()</code> method itself has no unit test coverage. The only test change was updating the kernel test assertion for <code>isUsable('text_to_image')</code>.</p> <p>The existing test suite has a good pattern for this <code>GeminiProviderChatTest</code> uses reflection and mocked clients to test <code>chat()</code> logic without hitting the API. The same approach should be applied to <code>textToImage()</code>.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Add a new <code>GeminiProviderTextToImageTest</code> unit test class (or extend existing test files) covering:</p> <ul> <li><code>TextToImageInput</code> is properly unwrapped to a plain string</li> <li>Plain string input is passed through correctly</li> <li><code>GenerationConfig</code> is built with <code>ResponseModality::IMAGE</code></li> <li><code>aspectRatio</code> configuration is passed to <code>ImageConfig</code> when set</li> <li><code>ImageConfig</code> is omitted when <code>aspectRatio</code> is not configured</li> <li>Response parts with <code>inlineData</code> are decoded into <code>ImageFile</code> objects with correct binary data, MIME type, and filename</li> <li>An empty response (no image parts) throws <code>AiResponseErrorException</code></li> <li>API exceptions are wrapped in <code>AiResponseErrorException</code></li> </ul> <p>[x] AI Assisted Issue<br> This issue was generated with AI assistance, but was reviewed and refined by the creator.</p> <p>[ ] AI Assisted Code<br> This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</p> <p>[ ] AI Generated Code<br> This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</p> <p>[ ] Vibe Coded<br> This code was generated by an AI and has only been functionally tested.</p> > Related issue: [Issue #3572953](https://www.drupal.org/node/3572953) > Related issue: [Issue #3572958](https://www.drupal.org/node/3572958)
issue