Create helper to mock iterators

Created on 20 April 2025, 5 days ago

Problem/Motivation

Steps to reproduce

I was unit testing some code which did a foreach ($entity->get('foo') as $item) and found a nice way to mock a field item list, asked in Slack how to contribute it back and cmlara said "We really do need more 'pre-made helpers' in core. All too often I hit a "why isn't there a pre-built mock for this?" situation." so here we are.

Proposed resolution

Add a helper.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

phpunit

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Charlie ChX Negyesi
  • Merge request !11892add getIteratorMock โ†’ (Open) created by Unnamed author
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada
  • Pipeline finished with Failed
    5 days ago
    Total: 123s
    #477707
  • Pipeline finished with Failed
    5 days ago
    Total: 96s
    #477712
  • Pipeline finished with Running
    5 days ago
    #477755
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Think we should include least one conversion spot where this could be useful

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    Added one.

    Converting an existing test is problematic: migrate tests are suitable but those are prophecy. My bad: when we added them (more than a decade ago, mind you) prophecy was fresh and it seemed to be the future. It seems by now this didn't turn out to be the case.

  • Pipeline finished with Failed
    5 days ago
    Total: 227s
    #477946
  • Pipeline finished with Failed
    5 days ago
    Total: 211s
    #477997
  • Pipeline finished with Failed
    5 days ago
    Total: 163s
    #477998
  • Pipeline finished with Failed
    5 days ago
    Total: 154s
    #478001
  • Pipeline finished with Canceled
    5 days ago
    Total: 167s
    #478010
  • Pipeline finished with Canceled
    5 days ago
    Total: 93s
    #478011
  • Pipeline finished with Failed
    5 days ago
    Total: 454s
    #478013
  • Pipeline finished with Failed
    5 days ago
    Total: 131s
    #478019
  • Pipeline finished with Success
    5 days ago
    Total: 626s
    #478020
  • Pipeline finished with Failed
    5 days ago
    Total: 688s
    #478028
  • Pipeline finished with Success
    5 days ago
    Total: 508s
    #478029
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada
  • Pipeline finished with Success
    4 days ago
    Total: 686s
    #478162
  • Pipeline finished with Success
    4 days ago
    Total: 455s
    #478377
  • Pipeline finished with Success
    4 days ago
    Total: 537s
    #478385
  • Pipeline finished with Failed
    4 days ago
    Total: 407s
    #478395
  • Pipeline finished with Canceled
    4 days ago
    Total: 121s
    #478409
  • Pipeline finished with Canceled
    4 days ago
    Total: 140s
    #478410
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada
  • Pipeline finished with Success
    4 days ago
    Total: 495s
    #478412
  • Pipeline finished with Success
    4 days ago
    Total: 616s
    #478418
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Left some small comments.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    I simply refuse to add more bloat. But, if it's required, I can just won't fix this, it's not so important.

  • First commit to issue fork.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nicxvan

    I've addressed the feedback on the MR.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    LGTM

Production build 0.71.5 2024