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 78
protected void
assertFileContains(array $contains, string $file, string $message = '')
Assert file contains the given strings.
in
InteractsWithPublishedFiles at line 96
protected void
assertFileDoesNotContains(array $contains, string $file, string $message = '')
Assert file does not contain the given strings.
in
InteractsWithPublishedFiles at line 114
protected void
assertFileNotContains(array $contains, string $file, string $message = '')
Assert file does not contain the given strings.
in
InteractsWithPublishedFiles at line 124
protected void
assertMigrationFileContains(array $contains, string $file, string $message = '', string|null $directory = null)
Assert migration file contains the given strings.
in
InteractsWithPublishedFiles at line 142
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 160
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 168
protected void
assertFilenameExists(string $file)
Assert filename exists.
in
InteractsWithPublishedFiles at line 178
protected void
assertFilenameDoesNotExists(string $file)
Assert filename does not exist.
in
InteractsWithPublishedFiles at line 188
protected void
assertFilenameNotExists(string $file)
Assert filename does not exist.
in
InteractsWithPublishedFiles at line 196
protected void
assertMigrationFileExists(string $file, string|null $directory = null)
Assert migration filename exists.
in
InteractsWithPublishedFiles at line 206
protected void
assertMigrationFileDoesNotExists(string $file, string|null $directory = null)
Assert migration filename does not exist.
in
InteractsWithPublishedFiles at line 216
protected void
assertMigrationFileNotExists(string $file, string|null $directory = null)
Assert migration filename does not exist.
in
InteractsWithPublishedFiles at line 226
protected void
cleanUpPublishedFiles()
| internal |
Removes generated files.
in
InteractsWithPublishedFiles at line 253
protected string|null
findFirstPublishedMigrationFile(string $filename, string|null $directory = null)
Find the first published migration file matching the filename.
in
InteractsWithPublishedFiles at line 267
protected void
cleanUpPublishedMigrationFiles()
| internal |
Removes generated migration files.
in
InteractsWithPublishedFiles at line 292
protected void
cleanUpPublishedFileSets()
Remove ordinary and migration publications independently.
in
InteractsWithPublishedFiles at line 316
protected string
publishedFilePath(string|SplFileInfo $file)
Normalize a published file entry into a filesystem path.
at line 36
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 44
protected string
baseSqliteDatabasePath()
Get the base sqlite database path before any parallel suffix is applied.
at line 68
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 83
protected void
useActiveSqliteDatabasePath(callable $callback)
Temporarily point the sqlite connection at the active runtime database file.
at line 123
protected void
withoutSqliteDatabase(callable $callback)
Drop Sqlite database.
at line 208
protected void
withSqliteDatabase(callable $callback)
Drop and create a new Sqlite database.
at line 275
static void
cleanupBackupSqliteDatabaseFilesOnFailed()
Clean up backup Sqlite database files after class teardown.