InteractsWithSqliteDatabaseFile
trait InteractsWithSqliteDatabaseFile
Traits
Provides assertion helpers and cleanup utilities for testing file publishing.
Properties
| protected bool | $interactsWithPublishedFilesTeardownRegistered | Determine if trait teardown has been registered. |
from InteractsWithPublishedFiles |
| protected null|array<int, string> | $cachedExistingMigrationsFiles | List of existing migration files. |
from InteractsWithPublishedFiles |
| protected array<int, string> | $files | List of generated files. |
Methods
Setup Interacts with Published Files environment.
Teardown Interacts with Published Files environment.
Cache existing migration files.
Assert file contains the given strings.
Assert file does not contain the given strings.
Assert file does not contain the given strings.
Assert migration file contains the given strings.
Assert migration file does not contain the given strings.
Assert migration file does not contain the given strings.
Assert filename does not exist.
Assert filename does not exist.
Assert migration filename exists.
Assert migration filename does not exist.
Assert migration filename does not exist.
Find the first published migration file matching the filename.
Removes generated migration files.
Remove ordinary and migration publications independently.
Normalize a published file entry into a filesystem path.
Purge the sqlite connection before swapping the runtime database file.
Get the base sqlite database path before any parallel suffix is applied.
Get the sqlite database path used by remote CLI commands in parallel.
Temporarily point the sqlite connection at the active runtime database file.
Drop Sqlite database.
Drop and create a new Sqlite database.
Clean up backup Sqlite database files after class teardown.
Details
in
InteractsWithPublishedFiles at line 39
protected void
setUpInteractsWithPublishedFiles()
| internal |
Setup Interacts with Published Files environment.
in
InteractsWithPublishedFiles at line 51
protected void
tearDownInteractsWithPublishedFiles()
| internal |
Teardown Interacts with Published Files environment.
in
InteractsWithPublishedFiles at line 64
protected void
cacheExistingMigrationsFiles()
| internal |
Cache existing migration files.
in
InteractsWithPublishedFiles at line 84
protected void
assertFileContains(array $contains, string $file, string $message = '')
Assert file contains the given strings.
in
InteractsWithPublishedFiles at line 104
protected void
assertFileDoesNotContains(array $contains, string $file, string $message = '')
Assert file does not contain the given strings.
in
InteractsWithPublishedFiles at line 124
protected void
assertFileNotContains(array $contains, string $file, string $message = '')
Assert file does not contain the given strings.
in
InteractsWithPublishedFiles at line 136
protected void
assertMigrationFileContains(array $contains, string $file, string $message = '', string|null $directory = null)
Assert migration file contains the given strings.
in
InteractsWithPublishedFiles at line 156
protected void
assertMigrationFileDoesNotContains(array $contains, string $file, string $message = '', string|null $directory = null)
Assert migration file does not contain the given strings.
in
InteractsWithPublishedFiles at line 176
protected void
assertMigrationFileNotContains(array $contains, string $file, string $message = '', string|null $directory = null)
Assert migration file does not contain the given strings.
in
InteractsWithPublishedFiles at line 186
protected void
assertFilenameExists(string $file)
Assert filename exists.
in
InteractsWithPublishedFiles at line 198
protected void
assertFilenameDoesNotExists(string $file)
Assert filename does not exist.
in
InteractsWithPublishedFiles at line 210
protected void
assertFilenameNotExists(string $file)
Assert filename does not exist.
in
InteractsWithPublishedFiles at line 220
protected void
assertMigrationFileExists(string $file, string|null $directory = null)
Assert migration filename exists.
in
InteractsWithPublishedFiles at line 232
protected void
assertMigrationFileDoesNotExists(string $file, string|null $directory = null)
Assert migration filename does not exist.
in
InteractsWithPublishedFiles at line 244
protected void
assertMigrationFileNotExists(string $file, string|null $directory = null)
Assert migration filename does not exist.
in
InteractsWithPublishedFiles at line 254
protected void
cleanUpPublishedFiles()
| internal |
Removes generated files.
in
InteractsWithPublishedFiles at line 283
protected string|null
findFirstPublishedMigrationFile(string $filename, string|null $directory = null)
Find the first published migration file matching the filename.
in
InteractsWithPublishedFiles at line 297
protected void
cleanUpPublishedMigrationFiles()
| internal |
Removes generated migration files.
in
InteractsWithPublishedFiles at line 328
protected void
cleanUpPublishedFileSets()
Remove ordinary and migration publications independently.
in
InteractsWithPublishedFiles at line 352
protected string
publishedFilePath(string|SplFileInfo $file)
Normalize a published file entry into a filesystem path.
at line 37
protected void
purgeSqliteConnection()
Purge the sqlite connection before swapping the runtime database file.
These helpers replace database.sqlite on disk while the parent test
process and remote CLI commands share the same runtime base path. The
testing resolver caches sqlite connections per worker, so the parent
process must drop its cached PDO handle before reading a newly swapped file.
at line 45
protected string
baseSqliteDatabasePath()
Get the base sqlite database path before any parallel suffix is applied.
at line 70
protected string
activeSqliteDatabasePath()
Get the sqlite database path used by remote CLI commands in parallel.
The commander subprocess boots a fresh Testbench application. When
DB_CONNECTION=sqlite and ParaTest sets TEST_TOKEN, Testbench rewrites
the sqlite database path to a token-suffixed file. The parent test process
must point its sqlite connection at that same file before asserting on it.
at line 88
protected void
useActiveSqliteDatabasePath(callable $callback)
Temporarily point the sqlite connection at the active runtime database file.
at line 130
protected void
withoutSqliteDatabase(callable $callback)
Drop Sqlite database.
at line 217
protected void
withSqliteDatabase(callable $callback)
Drop and create a new Sqlite database.
at line 284
static void
cleanupBackupSqliteDatabaseFilesOnFailed()
Clean up backup Sqlite database files after class teardown.