Files
pest/tests/Unit/Plugins/Tia/IsEnabledForRun.php
T
Conor Murphy ac8feafdcc fix: guard Tia argv scanning against non-string args (#1736)
The Tia plugin scans the raw argv with str_starts_with() in
argumentPresent() and hasExplicitPathArgument(). In the parallel worker
path (bin/worker.php) the unserialized argv can contain an integer
--random-order-seed value as a separate element, which made
str_starts_with() throw:

    TypeError: str_starts_with(): Argument #1 ($haystack) must be of
    type string, int given

This is the same class of bug as #1206, which was only fixed in
HandleArguments; it resurfaced in the newer Tia plugin. Cast each argv
element to string before scanning, mirroring the #1206 fix.

Adds a regression test, and updates the parallel count assertion and the
success snapshot to account for it.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 20:03:06 +01:00

21 lines
847 B
PHP

<?php
use Pest\Plugins\Tia;
test('does not throw when an integer --random-order-seed is passed as a separate argv element', function () {
// Mirrors the parallel worker argv (see bin/worker.php), where
// `--random-order-seed` and its value arrive as separate items and the
// seed value is an int rather than a string. Regression test for the
// str_starts_with() TypeError in Tia::argumentPresent() — the same class
// of bug as #1206, which was only fixed in HandleArguments.
$arguments = ['--order-by=random', '--random-order-seed', 1782350398];
expect(Tia::isEnabledForRun($arguments))->toBeFalse();
});
test('still detects --tia when an integer argument is present', function () {
$arguments = ['--tia', '--random-order-seed', 1782350398];
expect(Tia::isEnabledForRun($arguments))->toBeTrue();
});