mirror of
https://github.com/flarum/core.git
synced 2025-07-24 02:01:19 +02:00
Start transactions before the app is fully booted. (#11)
This make a cleaner state more likely, and ensures that settings set via `$this->setting` are cleaned up after the test case runs.
This commit is contained in:
committed by
GitHub
parent
675627ac15
commit
76a869a198
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Flarum\Testing\integration\Extend;
|
||||
|
||||
use Flarum\Extend\ExtenderInterface;
|
||||
use Flarum\Extension\Extension;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
|
||||
class BeginTransactionAndSetDatabase implements ExtenderInterface
|
||||
{
|
||||
/**
|
||||
* A callback to set the database connection object on the test case.
|
||||
*/
|
||||
protected $setDbOnTestCase;
|
||||
|
||||
public function __construct(callable $setDbOnTestCase)
|
||||
{
|
||||
$this->setDbOnTestCase = $setDbOnTestCase;
|
||||
}
|
||||
|
||||
public function extend(Container $container, Extension $extension = null)
|
||||
{
|
||||
$db = $container->make(ConnectionInterface::class);
|
||||
|
||||
$db->beginTransaction();
|
||||
|
||||
($this->setDbOnTestCase)($db);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user