Skip to content

test: cover lock id generation and negative TTL handling - #18

Merged
roxblnfk merged 1 commit into
1.xfrom
coverage
Oct 9, 2026
Merged

roxblnfk merged 1 commit into
1.xfrom
coverage

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Oct 9, 2026

Copy link
Copy Markdown
Member
Q A
Bugfix? ❌
Breaks BC? ❌
New feature? ❌
Issues —

Raises test coverage and makes the negative TTL tests check what Lock actually does. No changes in src.

Tests

  • Line coverage 48/51 → 53/53 statements (100%): UuidLockIdGenerator was never loaded by the suite before. Testo reports 43 → 48 tests.
  • Newly covered: UuidLockIdGenerator (default factory yields distinct UUID v4 ids, an injected factory is used) and Lock falling back to it when no id is given.
  • The five negative TTL tests passed by accident: they expected LogicException, which Mockery's BadMethodCallException for the unexpected RPC call satisfies, and failed with AssertionError under zend.assertions=1; the lockRead one called lock(). They are now one data-driven test expecting AssertionError, skipped when assertions are off. The testo workflow passes zend.assertions=1 so CI runs it.

Bugs found (skipped tests, not fixed here)

  • A negative ttl/waitTTL is only checked by assert(). The docblocks promise \InvalidArgumentException; in production (zend.assertions=-1) the negative value is sent to RoadRunner.

  • convertTimeToMicroseconds() reads only the seconds field of a \DateInterval (format('%s')): PT1M30S becomes 30 s, PT1H and P1D become 0 (forever), microseconds are dropped.

  • How was this tested:

    • Testo (with zend.assertions 1 and -1), psalm and php-cs-fixer run locally (PHP 8.4, Windows)

The negative TTL tests passed only because Mockery threw BadMethodCallException, a LogicException, on the unexpected RPC call; with zend.assertions=1 they failed with AssertionError, and the lockRead one called lock(). They now expect the AssertionError and run with assertions enabled in CI. Two skipped tests document bugs: a negative TTL never throws the documented InvalidArgumentException, and a DateInterval TTL loses everything but its seconds field.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk requested a review from a team October 9, 2026 19:43
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a3f39a5-3b69-4605-b2b3-ae53342c0f14

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@roxblnfk
roxblnfk merged commit f80c8cc into 1.x Oct 9, 2026
14 checks passed
@roxblnfk
roxblnfk deleted the coverage branch October 9, 2026 19:49
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