Skip to content

Support predicate callbacks in fake index assertions#4

Merged
stevebauman merged 1 commit into
masterfrom
agent/fix-index-fake-assertions
Jul 24, 2026
Merged

Support predicate callbacks in fake index assertions#4
stevebauman merged 1 commit into
masterfrom
agent/fix-index-fake-assertions

Conversation

@stevebauman

@stevebauman stevebauman commented Jul 24, 2026

Copy link
Copy Markdown
Member

What changed

  • Allow fake index creation assertions to match an index by name without requiring an exact IndexBlueprint.
  • Support optional predicate callbacks that inspect the recorded blueprint, mapping, or settings.
  • Preserve exact IndexBlueprint, Mapping, and Settings assertions for backward compatibility.
  • Add coverage for successful name-only assertions, successful predicates, missing operations, and predicates that return false.

Why

The fake previously treated expected mapping and settings objects as exact operation definitions. This made higher-level assertions fail when an index was created with mapping or settings data that the assertion did not explicitly rebuild. Assertion callbacks should inspect the operation that was actually recorded, following the same predicate semantics used by Laravel's fakes.

Developer impact

Consumers can now assert only that an operation occurred:

$index->assertCreated('users');
$index->assertMappingPut('users');
$index->assertSettingsPut('users');

They can optionally add a predicate when the recorded definition matters, while existing exact-object assertions continue to work.

@stevebauman
stevebauman marked this pull request as ready for review July 24, 2026 16:32
@stevebauman
stevebauman merged commit 0397366 into master Jul 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant