mirror of
https://github.com/pestphp/pest.git
synced 2026-09-06 23:03:34 +02:00
Compare commits
2 Commits
v5.0.3
...
19eed8d581
| Author | SHA1 | Date | |
|---|---|---|---|
| 19eed8d581 | |||
| ad1850b110 |
+1
-1
@@ -1065,7 +1065,7 @@ final class Tia implements AddsOutput, HandlesArguments, Terminable
|
|||||||
{
|
{
|
||||||
$this->output->writeln('');
|
$this->output->writeln('');
|
||||||
|
|
||||||
$this->renderChild('Running in TIA mode, however TIA as skipped as it needs Needs ext-pcov or Xdebug.');
|
$this->renderChild('Running in TIA mode, however TIA is skipped as it needs ext-pcov or Xdebug.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ final class TableExtractor
|
|||||||
$tables[strtolower($name)] = true;
|
$tables[strtolower($name)] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array_keys($tables);
|
$out = array_map(strval(...), array_keys($tables));
|
||||||
sort($out);
|
sort($out);
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
@@ -112,7 +112,7 @@ final class TableExtractor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array_keys($tables);
|
$out = array_map(strval(...), array_keys($tables));
|
||||||
sort($out);
|
sort($out);
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ describe('fromSql()', function (): void {
|
|||||||
->and(TableExtractor::fromSql('select * from information_schema.tables'))->toBeEmpty();
|
->and(TableExtractor::fromSql('select * from information_schema.tables'))->toBeEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not leak int keys for numeric identifiers', function (): void {
|
||||||
|
// `substring(x FROM 1 FOR 3)` is standard SQL, and the `1` matches the
|
||||||
|
// FROM pattern. Collecting names as array keys makes PHP coerce the
|
||||||
|
// numeric string to an int, which then violates the declared
|
||||||
|
// list<string> and blows up Recorder::linkTable(string).
|
||||||
|
expect(TableExtractor::fromSql('select substring(name from 1 for 3) from users'))
|
||||||
|
->each->toBeString();
|
||||||
|
});
|
||||||
|
|
||||||
it('returns nothing for non-DML statements', function (): void {
|
it('returns nothing for non-DML statements', function (): void {
|
||||||
expect(TableExtractor::fromSql('PRAGMA foreign_keys = ON'))->toBeEmpty()
|
expect(TableExtractor::fromSql('PRAGMA foreign_keys = ON'))->toBeEmpty()
|
||||||
->and(TableExtractor::fromSql(''))->toBeEmpty()
|
->and(TableExtractor::fromSql(''))->toBeEmpty()
|
||||||
@@ -89,6 +98,14 @@ describe('fromMigrationSource()', function (): void {
|
|||||||
->toBe(['audits', 'events', 'sessions', 'settings', 'users']);
|
->toBe(['audits', 'events', 'sessions', 'settings', 'users']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not leak int keys for numeric table names', function (): void {
|
||||||
|
// A table named `123` is a legal quoted identifier. Collecting names as
|
||||||
|
// array keys makes PHP coerce it to an int, breaking the declared
|
||||||
|
// list<string>, so it must survive as a string rather than be dropped.
|
||||||
|
expect(TableExtractor::fromMigrationSource("DB::table('123')->insert([]);"))
|
||||||
|
->toBe(['123']);
|
||||||
|
});
|
||||||
|
|
||||||
it('extracts tables from DB::table calls', function (): void {
|
it('extracts tables from DB::table calls', function (): void {
|
||||||
expect(TableExtractor::fromMigrationSource("DB::table('permissions')->insert([]);"))
|
expect(TableExtractor::fromMigrationSource("DB::table('permissions')->insert([]);"))
|
||||||
->toBe(['permissions']);
|
->toBe(['permissions']);
|
||||||
|
|||||||
Reference in New Issue
Block a user