mirror of
https://github.com/pestphp/pest.git
synced 2026-12-06 15:52:16 +01:00
fix(tia): keep numeric file, branch and page names as strings (#2066)
Co-authored-by: Punyapal Shah <53343069+MrPunyapal@users.noreply.github.com> Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
+2
-1
@@ -36,6 +36,7 @@ use Pest\Plugins\Tia\SourceScope;
|
||||
use Pest\Plugins\Tia\Storage;
|
||||
use Pest\Plugins\Tia\TableExtractor;
|
||||
use Pest\Plugins\Tia\WatchPatterns;
|
||||
use Pest\Support\Arr;
|
||||
use Pest\Support\Ci;
|
||||
use Pest\Support\Container;
|
||||
use Pest\Support\Git;
|
||||
@@ -1765,7 +1766,7 @@ final class Tia implements AddsOutput, HandlesArguments, HandlesOriginalArgument
|
||||
return [
|
||||
array_map(array_keys(...), $merged['files']),
|
||||
array_map(static fn (array $tables): array => array_map(strval(...), array_keys($tables)), $merged['tables']),
|
||||
array_map(array_keys(...), $merged['inertia']),
|
||||
array_map(Arr::stringKeys(...), $merged['inertia']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Pest\Plugins\Tia;
|
||||
|
||||
use Pest\Exceptions\MissingDependency;
|
||||
use Pest\Exceptions\TiaGitFailed;
|
||||
use Pest\Support\Arr;
|
||||
use Pest\Support\Git;
|
||||
use Symfony\Component\Process\ExecutableFinder;
|
||||
|
||||
@@ -78,7 +79,7 @@ final class ChangedFiles
|
||||
*/
|
||||
public function outsideProject(): array
|
||||
{
|
||||
return array_map(strval(...), array_keys($this->outsideProject));
|
||||
return Arr::stringKeys($this->outsideProject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +87,7 @@ final class ChangedFiles
|
||||
*/
|
||||
public function outsideProjectDirty(): array
|
||||
{
|
||||
return array_map(strval(...), array_keys($this->outsideProjectDirty));
|
||||
return Arr::stringKeys($this->outsideProjectDirty);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,13 +103,13 @@ final class ChangedFiles
|
||||
|
||||
$candidates = array_fill_keys($files, true);
|
||||
|
||||
foreach (array_keys($lastRunTree) as $snapshotted) {
|
||||
foreach (Arr::stringKeys($lastRunTree) as $snapshotted) {
|
||||
$candidates[$snapshotted] = true;
|
||||
}
|
||||
|
||||
$remaining = [];
|
||||
|
||||
foreach (array_keys($candidates) as $file) {
|
||||
foreach (Arr::stringKeys($candidates) as $file) {
|
||||
$snapshot = $lastRunTree[$file] ?? null;
|
||||
$current = $this->currentHash($file);
|
||||
|
||||
@@ -189,7 +190,7 @@ final class ChangedFiles
|
||||
$unique[$file] = true;
|
||||
}
|
||||
|
||||
$candidates = array_keys($this->filterIgnored($unique));
|
||||
$candidates = Arr::stringKeys($this->filterIgnored($unique));
|
||||
|
||||
$this->filterIgnoredOutsideProject();
|
||||
|
||||
@@ -374,7 +375,7 @@ final class ChangedFiles
|
||||
}
|
||||
}
|
||||
|
||||
return array_keys($names);
|
||||
return Arr::stringKeys($names);
|
||||
}
|
||||
|
||||
public function hasRemote(): bool
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Pest\Plugins\Tia;
|
||||
use JsonException;
|
||||
use Pest\Factories\TestCaseFactory;
|
||||
use Pest\Factories\TestCaseMethodFactory;
|
||||
use Pest\Support\Arr;
|
||||
use Pest\Support\Container;
|
||||
use Pest\Support\View;
|
||||
use Pest\TestSuite;
|
||||
@@ -594,7 +595,7 @@ final class Graph
|
||||
{
|
||||
$generated = [];
|
||||
|
||||
foreach ($this->fileIds as $path => $id) {
|
||||
foreach ($this->files as $id => $path) {
|
||||
$hash = $this->livewireGeneratedHash($path);
|
||||
|
||||
if ($hash === null) {
|
||||
@@ -1131,7 +1132,7 @@ final class Graph
|
||||
}
|
||||
}
|
||||
|
||||
$names = array_keys($normalised);
|
||||
$names = Arr::stringKeys($normalised);
|
||||
sort($names);
|
||||
|
||||
$this->testInertiaComponents[$testRel] = $names;
|
||||
@@ -1161,7 +1162,7 @@ final class Graph
|
||||
continue;
|
||||
}
|
||||
|
||||
$keys = array_keys($names);
|
||||
$keys = Arr::stringKeys($names);
|
||||
sort($keys);
|
||||
$out[$path] = $keys;
|
||||
}
|
||||
@@ -1645,7 +1646,7 @@ final class Graph
|
||||
{
|
||||
$survivors = array_fill_keys($keep, true);
|
||||
|
||||
foreach (array_keys($this->baselines) as $branch) {
|
||||
foreach (Arr::stringKeys($this->baselines) as $branch) {
|
||||
if (str_starts_with($branch, self::WORKSPACE_BRANCH_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1711,8 +1712,8 @@ final class Graph
|
||||
|
||||
$branches = [];
|
||||
|
||||
foreach (array_keys($data['baselines']) as $branch) {
|
||||
if (is_string($branch) && $branch !== '') {
|
||||
foreach (Arr::stringKeys($data['baselines']) as $branch) {
|
||||
if ($branch !== '') {
|
||||
$branches[] = $branch;
|
||||
}
|
||||
}
|
||||
@@ -1847,8 +1848,8 @@ final class Graph
|
||||
|
||||
if (is_array($baseline['tree'] ?? null)) {
|
||||
foreach ($baseline['tree'] as $path => $hash) {
|
||||
if (is_string($path) && is_string($hash)) {
|
||||
$tree[$path] = $hash;
|
||||
if (is_string($hash)) {
|
||||
$tree[(string) $path] = $hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins\Tia;
|
||||
|
||||
use Pest\Support\Arr;
|
||||
use Pest\Support\Container;
|
||||
use Pest\TestSuite;
|
||||
use ReflectionClass;
|
||||
@@ -329,7 +330,7 @@ final class Recorder
|
||||
$out = [];
|
||||
|
||||
foreach ($this->perTestInertiaComponents as $testFile => $components) {
|
||||
$names = array_keys($components);
|
||||
$names = Arr::stringKeys($components);
|
||||
sort($names);
|
||||
$out[$testFile] = $names;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Pest\Plugins\Tia;
|
||||
|
||||
use Pest\Plugins\Tia\Contracts\WatchDefault;
|
||||
use Pest\Support\Arr;
|
||||
use Pest\TestSuite;
|
||||
|
||||
/**
|
||||
@@ -173,7 +174,7 @@ final class WatchPatterns
|
||||
}
|
||||
}
|
||||
|
||||
return array_keys($matched);
|
||||
return Arr::stringKeys($matched);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,17 +185,17 @@ final class WatchPatterns
|
||||
{
|
||||
$matched = [];
|
||||
|
||||
foreach ($patterns as $key => $dirs) {
|
||||
foreach (Arr::stringKeys($patterns) as $key) {
|
||||
if (! $this->keyMatches($key, $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($dirs as $dir) {
|
||||
foreach ($patterns[$key] as $dir) {
|
||||
$matched[$dir] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return array_keys($matched);
|
||||
return Arr::stringKeys($matched);
|
||||
}
|
||||
|
||||
private function usesDefaultsFor(string $file): bool
|
||||
|
||||
@@ -9,6 +9,15 @@ namespace Pest\Support;
|
||||
*/
|
||||
final class Arr
|
||||
{
|
||||
/**
|
||||
* @param array<array-key, mixed> $array
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function stringKeys(array $array): array
|
||||
{
|
||||
return array_map(strval(...), array_keys($array));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array-key, mixed> $array
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user