-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/11.x' into 11.x
- Loading branch information
Showing
6 changed files
with
105 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...abase/EloquentTransactionWithAfterCommitUsingRefreshDatabaseOnMultipleConnectionsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Integration\Database; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
use Orchestra\Testbench\Attributes\WithConfig; | ||
|
||
use function Orchestra\Testbench\artisan; | ||
|
||
#[WithConfig('database.connections.second', ['driver' => 'sqlite', 'database' => ':memory:', 'foreign_key_constraints' => false])] | ||
class EloquentTransactionWithAfterCommitUsingRefreshDatabaseOnMultipleConnectionsTest extends EloquentTransactionWithAfterCommitUsingRefreshDatabaseTest | ||
{ | ||
/** {@inheritDoc} */ | ||
protected function connectionsToTransact() | ||
{ | ||
return [null, 'second']; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
protected function afterRefreshingDatabase() | ||
{ | ||
artisan($this, 'migrate', ['--database' => 'second']); | ||
} | ||
|
||
public function testAfterCommitCallbacksAreCalledCorrectlyWhenNoAppTransaction() | ||
{ | ||
$called = false; | ||
|
||
DB::afterCommit(function () use (&$called) { | ||
$called = true; | ||
}); | ||
|
||
$this->assertTrue($called); | ||
} | ||
|
||
public function testAfterCommitCallbacksAreCalledWithWrappingTransactionsCorrectly() | ||
{ | ||
$calls = []; | ||
|
||
DB::transaction(function () use (&$calls) { | ||
DB::afterCommit(function () use (&$calls) { | ||
$calls[] = 'first transaction callback'; | ||
}); | ||
|
||
DB::connection('second')->transaction(function () use (&$calls) { | ||
DB::connection('second')->afterCommit(function () use (&$calls) { | ||
$calls[] = 'second transaction callback'; | ||
}); | ||
}); | ||
}); | ||
|
||
$this->assertEquals([ | ||
'second transaction callback', | ||
'first transaction callback', | ||
], $calls); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters