Problem/Motivation

Create a test for getPredifinedModelsAsOptions so it create an options array for form api.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork ai-3488377

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

marcus_johansson created an issue. See original summary.

mjb3141’s picture

Assigned: Unassigned » mjb3141

spec0 made their first commit to this issue’s fork.

marcus_johansson’s picture

Version: 1.0.x-dev » 1.2.x-dev
Status: Active » Needs work

Seems to be failing

marcus_johansson’s picture

Version: 1.2.x-dev » 2.0.x-dev
Assigned: mjb3141 » Unassigned

harivansh made their first commit to this issue’s fork.

harivansh’s picture

Status: Needs work » Needs review
harivansh’s picture

I was wondering if we should create an issue to update the existing test implementation to use attributes.

thamas’s picture

Status: Needs review » Needs work

The MR has a lot of validation and test problems.

hrishikesh-dalal’s picture

Hey

I would love to help here! Could I assign myself this and freshly work on the Unit Test?

scott falconer’s picture

@hrishikesh-dalal that sounds great! Go ahead and assign yourself and let us know if you have any questions.

hrishikesh-dalal’s picture

Sure thanks! I will get it completed by today itself

hrishikesh-dalal’s picture

Assigned: Unassigned » hrishikesh-dalal

hrishikesh-dalal changed the visibility of the branch 1.0.x to hidden.

abhisekmazumdar’s picture

@hrishikesh-dalal

I checked the MR you created: https://git.drupalcode.org/project/ai/-/merge_requests/1238

Firstly, thank you for the work so far, it’s really appreciated.

I haven’t done a deep code review yet, but I have some initial thoughts comparing the two merge requests:

- MR339 has broader test coverage and validates against the real YAML files shipped with the module. This is useful because it ensures the actual predefined model definitions in the module remain correct and don’t break over time.

- MR1238 takes a more isolated unit-testing approach by using a virtual filesystem. This makes the test more portable, deterministic, and aligned with unit-testing best practices, since it doesn’t depend on the module’s physical file structure.

My initial feeling is that MR 1238 follows better unit-testing practices, while MR 339 provides stronger real-world validation and broader scenario coverage. Ideally, a combination of both approaches would give the best overall test reliability and coverage.

See if it’s possible to achieve that balance.

Regarding the broken PHPStan checks, this is a known issue, and other MRs targeting the 2.x branch also have it. A good way to confirm is to look at other MRs and issues targeting the same branch.

For example, the Needs review queue for 2.x:
https://www.drupal.org/project/issues/search/ai?status%5B%5D=8&version%5...

You’ll notice that several 2.x MRs are currently affected. I haven’t investigated those errors in detail, but there are likely existing issues tracking them.

hrishikesh-dalal’s picture

Appreciate the feedback, @abhisekmazumdar. I see the point regarding the coverage in MR 339. I'll bridge the gap by bringing those scenarios into my isolated setup in MR 1238.

Thanks for clarifying the PHPStan issue as well—saved me some unnecessary debugging. I'll update the MR shortly.

Thank you!

hrishikesh-dalal’s picture

Assigned: hrishikesh-dalal » Unassigned
Status: Needs work » Needs review

hrishikesh-dalal changed the visibility of the branch hrishikesh-dalal-1.0.x-patch-b2ee to hidden.

hrishikesh-dalal changed the visibility of the branch 3488377-create-unit-test-2x to hidden.

hrishikesh-dalal changed the visibility of the branch hrishikesh-dalal-1.0.x-patch-b2ee to active.

hrishikesh-dalal changed the visibility of the branch 3488377-create-unit-test to hidden.

scott falconer’s picture

Assigned: Unassigned » scott falconer
Status: Needs review » Reviewed & tested by the community

I reviewed MR !1238 as the active candidate for this issue and did not find any blocking issues.

Summary

- Scope is tight and matches the issue (single new unit test file).
- The test coverage is solid for the targeted utility behavior.
- Latest MR pipeline is successful overall.

Blockers

- None.

Optional recommendation

- Add explicit negative-path wrapper tests for:
- getPredefinedModelsAsOptions(NULL|invalid)
- getPredefinedModel(invalid, ...)

marking as rtbc

scott falconer’s picture

Assigned: scott falconer » Unassigned