Skip to content

Fix fake index assertion callback semantics#2

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

Fix fake index assertion callback semantics#2
stevebauman merged 8 commits into
masterfrom
agent/fix-index-fake-assertions

Conversation

@stevebauman

Copy link
Copy Markdown
Member

What changed

  • Make assertCreated() match the recorded index by name when no callback is provided.
  • Treat callbacks passed to assertCreated(), assertMappingPut(), and assertSettingsPut() as predicates against the actual recorded mapping and settings.
  • Make mapping and settings callbacks optional so callers can assert only that the operation occurred.
  • Require OpenSearchAdapter ^1.2.1 for the corresponding fake assertion support.
  • Add coverage for successful predicates and predicates that return false.

Why

The fake previously used assertion callbacks as builders for a second expected mapping or settings object. A name-only assertion could therefore fail when the recorded index contained fields that the assertion did not reproduce. This differs from Laravel fake assertions, where a callback inspects the operation that was actually dispatched and returns whether it matches.

Developer impact

Assertions can now focus on the operation:

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

A predicate can be added only when the recorded definition needs further inspection.

Dependency

Depends on DirectoryTree/OpenSearchAdapter#4. The adapter should be released as v1.2.1 before this package is released.

Validation

  • vendor/bin/pint
  • vendor/bin/pest — 96 tests, 205 assertions on the master-based branch
  • git diff --check

@stevebauman
stevebauman marked this pull request as ready for review July 24, 2026 16:43
@stevebauman
stevebauman merged commit 786c51e into master Jul 24, 2026
7 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