Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Support/BrowserTestIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static function usesFunction(Closure $closure, string $functionName): bo
return true;
}

return $tokens[$i - 1][0] === T_WHITESPACE;
return $tokens[$i - 1][0] === T_WHITESPACE || $tokens[$i - 1] === '(';
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/Unit/Support/BrowserTestIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ function callUsesFunction(Closure $closure, string $functionName): bool
expect(callUsesFunction($closure, 'visit'))->toBeTrue();
});

// visit detection — wrapped in another function call

it('detects visit() wrapped in another function call', function (): void {
$closure = function (): void {
acknowledgeEnvironment(visit('/'));
};

expect(callUsesFunction($closure, 'visit'))->toBeTrue();
});

it('detects \visit() wrapped in another function call', function (): void {
$closure = function (): void {
acknowledgeEnvironment(\visit('/'));
};

expect(callUsesFunction($closure, 'visit'))->toBeTrue();
});

// visit detection — Livewire

it('detects Livewire::visit()', function (): void {
Expand Down