REDROOM
PHP 8.3.31
Path:
Logout
Edit File
Size: 4.03 KB
Close
/home/getspomw/royalsquad.us/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php
Text
Base64
<?php namespace Illuminate\Foundation\Testing; use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Testing\Traits\CanConfigureMigrationCommands; trait RefreshDatabase { use CanConfigureMigrationCommands; /** * Define hooks to migrate the database before and after each test. * * @return void */ public function refreshDatabase() { $this->beforeRefreshingDatabase(); if ($this->usingInMemoryDatabase()) { $this->restoreInMemoryDatabase(); } $this->refreshTestDatabase(); $this->afterRefreshingDatabase(); } /** * Determine if an in-memory database is being used. * * @return bool */ protected function usingInMemoryDatabase() { $default = config('database.default'); return config("database.connections.$default.database") === ':memory:'; } /** * Restore the in-memory database between tests. * * @return void */ protected function restoreInMemoryDatabase() { $database = $this->app->make('db'); foreach ($this->connectionsToTransact() as $name) { if (isset(RefreshDatabaseState::$inMemoryConnections[$name])) { $database->connection($name)->setPdo(RefreshDatabaseState::$inMemoryConnections[$name]); } } } /** * Refresh a conventional test database. * * @return void */ protected function refreshTestDatabase() { if (! RefreshDatabaseState::$migrated) { $this->artisan('migrate:fresh', $this->migrateFreshUsing()); $this->app[Kernel::class]->setArtisan(null); RefreshDatabaseState::$migrated = true; } $this->beginDatabaseTransaction(); } /** * Begin a database transaction on the testing database. * * @return void */ public function beginDatabaseTransaction() { $database = $this->app->make('db'); $connections = $this->connectionsToTransact(); $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager($connections)); foreach ($connections as $name) { $connection = $database->connection($name); $connection->setTransactionManager($transactionsManager); if ($this->usingInMemoryDatabase()) { RefreshDatabaseState::$inMemoryConnections[$name] ??= $connection->getPdo(); } $dispatcher = $connection->getEventDispatcher(); $connection->unsetEventDispatcher(); $connection->beginTransaction(); $connection->setEventDispatcher($dispatcher); } $this->beforeApplicationDestroyed(function () use ($database) { foreach ($this->connectionsToTransact() as $name) { $connection = $database->connection($name); $dispatcher = $connection->getEventDispatcher(); $connection->unsetEventDispatcher(); if ($connection->getPdo() && ! $connection->getPdo()->inTransaction()) { RefreshDatabaseState::$migrated = false; } $connection->rollBack(); $connection->setEventDispatcher($dispatcher); $connection->disconnect(); } }); } /** * The database connections that should have transactions. * * @return array */ protected function connectionsToTransact() { return property_exists($this, 'connectionsToTransact') ? $this->connectionsToTransact : [null]; } /** * Perform any work that should take place before the database has started refreshing. * * @return void */ protected function beforeRefreshingDatabase() { // ... } /** * Perform any work that should take place once the database has finished refreshing. * * @return void */ protected function afterRefreshingDatabase() { // ... } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 2 × Files: 12
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Concerns
DIR
-
drwxrwxrwx
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Traits
DIR
-
drwxrwxrwx
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseMigrations.php
1.36 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseTransactions.php
1.61 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseTransactionsManager.php
1.83 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DatabaseTruncation.php
6.44 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LazilyRefreshDatabase.php
1.15 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RefreshDatabase.php
4.03 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RefreshDatabaseState.php
516 B
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TestCase.php
1.80 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
WithConsoleEvents.php
344 B
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
WithFaker.php
1.21 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
WithoutMiddleware.php
500 B
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Wormhole.php
5.73 KB
lrw-rw-rw-
2025-09-17 06:52:55
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).