Skip to content

test: add unit tests for Link model methods#22

Merged
sanmaxdev merged 1 commit into
sanmaxdev:mainfrom
miguelm-montano:feat/unit-tests-link-model
Jul 6, 2026
Merged

test: add unit tests for Link model methods#22
sanmaxdev merged 1 commit into
sanmaxdev:mainfrom
miguelm-montano:feat/unit-tests-link-model

Conversation

@miguelm-montano

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the first unit tests for the Link model, covering all its pure-logic methods. The tests/Unit/ directory was completely empty before this PR.

Methods covered: normalizeTags(), appendParams(), isExpired(), isOverLimit(), hasDeepLinks(), deepLinkFor(), and cacheKey() — 38 tests, 44 assertions

Related issue

Closes #19

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore

Checklist

  • I ran vendor/bin/pint (code style passes)
  • I ran php artisan test (all tests pass) and added/updated tests for my change
  • npm run build succeeds (if I touched front-end assets)
  • I updated the documentation where relevant
  • My change does not introduce a license check, phone-home, or other commercial gating

Notes for reviewers

No production code was modified — only tests/Unit/LinkTest.php was added.

Tests use Tests\TestCase as base class (needed for Eloquent's datetime cast resolution) but do not touch the database, no RefreshDatabase, no factories, no seeders.

A follow-up PR is planned to add feature tests for click tracking edge cases (bot detection, null IP, password-protected links, etc.).

@sanmaxdev sanmaxdev left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this. I checked the Link model coverage against the current implementation and ran the relevant checks.

Passed:

  • vendor/bin/pint --test
  • php artisan test
  • git diff --check origin/main...HEAD

@sanmaxdev sanmaxdev merged commit a05390f into sanmaxdev:main Jul 6, 2026
4 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.

Grow automated test coverage (link, analytics & admin flows)

2 participants