Fix Validation Errors
This guide shows how to identify and fix common TestLink validation errors.
Running Validation
./vendor/bin/testlink validateCommon Errors and Solutions
1. Orphan TestedBy
Error:
✗ Found 1 orphan TestedBy link(s):
App\UserService::create
→ Tests\UserServiceTest::test_creates_user (test not found)Cause: A #[TestedBy] attribute exists in production code, but the test doesn't have a corresponding test link (->linksAndCovers() in Pest, #[LinksAndCovers] in PHPUnit, or @see tag).
Solutions:
Option A: Add the missing link in the test:
test('creates user', function () {
// ...
})->linksAndCovers(UserService::class.'::create');Option B: Remove the #[TestedBy] if the test was removed:
// Remove this line if test no longer exists
// #[TestedBy('Tests\UserServiceTest', 'test_creates_user')]
public function create(array $data): UserOption C: Run sync to auto-fix:
./vendor/bin/testlink sync2. Missing TestedBy
Error:
⚠ Found 1 test link(s) without TestedBy:
Tests\UserServiceTest::test_creates_user
→ App\UserService::create (no TestedBy attribute)Cause: A test has a link (->linksAndCovers(), #[LinksAndCovers], or @see), but the production method doesn't have #[TestedBy].
Solutions:
Option A: Add the missing #[TestedBy]:
#[TestedBy('Tests\UserServiceTest', 'test_creates_user')]
public function create(array $data): UserOption B: Run sync with link-only mode:
./vendor/bin/testlink sync --link-only3. Duplicate Links
Error:
✗ Found 1 duplicate link(s):
Tests\UserServiceTest::test_creates_user
→ App\UserService::create
Found in: PHPUnit attribute, Pest method chainCause: The same link is declared in both a PHPUnit attribute AND a Pest method chain.
Solution: Remove one of the duplicates. Keep only:
// Either use the attribute
#[LinksAndCovers(UserService::class, 'create')]
public function test_creates_user(): void
// OR use the method chain
test('creates user', function () {
// ...
})->linksAndCovers(UserService::class.'::create');4. Unresolved Placeholder
Error:
✗ Found 1 unresolved placeholder(s):
@user-create
Production: App\UserService::create
Tests: Tests\UserServiceTest::test_creates_userCause: A placeholder marker hasn't been resolved to real references.
Solution: Run the pair command:
# Preview first
./vendor/bin/testlink pair --dry-run
# Apply changes
./vendor/bin/testlink pair5. Invalid Test Reference
Error:
✗ Found 1 invalid TestedBy reference(s):
App\UserService::create
→ Tests\UserServiceTest::test_nonexistent (test not found)Cause: The #[TestedBy] points to a test that doesn't exist.
Solutions:
Option A: Fix the test name:
// Wrong
#[TestedBy('Tests\UserServiceTest', 'test_nonexistent')]
// Correct
#[TestedBy('Tests\UserServiceTest', 'test_creates_user')]Option B: Remove if test was deleted:
// Remove the stale TestedBy
public function create(array $data): User6. Invalid Method Reference
Error:
✗ Found 1 invalid linksAndCovers reference(s):
Tests\UserServiceTest::test_creates_user
→ App\UserService::nonexistent (method not found)Cause: The test link points to a method that doesn't exist.
Solution: Fix the method reference:
// Wrong
->linksAndCovers(UserService::class.'::nonexistent')
// Correct
->linksAndCovers(UserService::class.'::create')7. FQCN Issue in @see Tag
Error:
⚠ Found 1 @see tag FQCN issue(s):
tests/UserServiceTest.php:15
@see UserService::create (should use FQCN: \App\UserService)Cause: An @see tag uses a short class name instead of fully qualified.
Solution: Use the full class name:
// Wrong
/** @see UserService::create */
// Correct
/** @see \App\UserService::create */
// Or with use statement
use App\UserService;
/** @see UserService::create */Batch Fixing
Fix all sync issues
./vendor/bin/testlink syncFix all placeholder issues
./vendor/bin/testlink pairFix orphaned @see tags
./vendor/bin/testlink sync --pruneDry-Run First
Always preview changes before applying:
# Preview sync changes
./vendor/bin/testlink sync --dry-run
# Preview pair changes
./vendor/bin/testlink pair --dry-runVerbose Output
For more details about errors:
./vendor/bin/testlink validate --verboseThis shows:
- File paths
- Line numbers
- Additional context
Suppressing Warnings
If you want to ignore certain warnings temporarily:
# Only fail on errors, not warnings
./vendor/bin/testlink validate
# Fail on both errors and warnings
./vendor/bin/testlink validate --strictCommon Causes of Errors
| Error | Common Cause |
|---|---|
| Orphan TestedBy | Test was renamed or deleted |
| Missing TestedBy | New test added without updating production |
| Duplicate links | Mixed PHPUnit attributes with Pest chains |
| Unresolved placeholder | Forgot to run pair before committing |
| Invalid reference | Typo in class or method name |