Bidirectional Links
Link tests to production and production to tests. TestedBy on code, LinksAndCovers on tests.
Framework-agnostic test-to-code linking for PHP. Works with Pest and PHPUnit.

Mark production methods with the tests that cover them:
<?php
namespace App\Services;
use TestFlowLabs\TestingAttributes\TestedBy;
class UserService
{
#[TestedBy(UserServiceTest::class, 'test_creates_a_new_user')]
#[TestedBy(UserServiceTest::class, 'test_validates_user_email')]
public function create(array $data): User
{
// Implementation
}
}Link your tests to production methods:
test('creates a new user', function () {
$user = app(UserService::class)->create([
'name' => 'John',
'email' => 'john@example.com',
]);
expect($user)->toBeInstanceOf(User::class);
})->linksAndCovers(UserService::class.'::create');
test('validates user email', function () {
expect(fn () => app(UserService::class)->create([
'email' => 'invalid',
]))->toThrow(ValidationException::class);
})->linksAndCovers(UserService::class.'::create');use TestFlowLabs\TestingAttributes\LinksAndCovers;
class UserServiceTest extends TestCase
{
#[LinksAndCovers(UserService::class, 'create')]
public function test_creates_a_new_user(): void
{
$user = app(UserService::class)->create([
'name' => 'John',
'email' => 'john@example.com',
]);
$this->assertInstanceOf(User::class, $user);
}
#[LinksAndCovers(UserService::class, 'create')]
public function test_validates_user_email(): void
{
$this->expectException(ValidationException::class);
app(UserService::class)->create([
'email' => 'invalid',
]);
}
}Use the standalone CLI that works with any framework:
$ testlink validate
Validation Report:
✓ All links are valid!
PHPUnit attribute links: 2
Pest method chain links: 0
Total links: 2$ testlink report
Coverage Links Report
─────────────────────
UserService::create
→ UserServiceTest::test_creates_a_new_user
→ UserServiceTest::test_validates_user_email
Summary:
Methods: 1
Tests: 2TestLink works seamlessly with other TestFlowLabs packages:
#[LinksAndCovers], #[Links], etc.)Together, these packages provide a complete testing workflow from behavior specification to implementation validation.