-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractModelTestCase.php
More file actions
41 lines (31 loc) · 1.02 KB
/
AbstractModelTestCase.php
File metadata and controls
41 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace InitORM\ORM\Tests\Support;
use InitORM\Database\Database;
use InitORM\Database\Facade\DB;
use InitORM\Database\Interfaces\DatabaseInterface;
use InitORM\DBAL\Connection\Interfaces\ConnectionInterface;
use PHPUnit\Framework\TestCase;
/**
* Base test case that gives each test a fresh in-memory SQLite connection
* wired through the {@see DB} facade, and tears the facade slot down again
* afterwards so tests do not bleed state into one another.
*/
abstract class AbstractModelTestCase extends TestCase
{
protected ConnectionInterface $connection;
protected DatabaseInterface $db;
protected function setUp(): void
{
parent::setUp();
$this->connection = SqliteHelper::makeConnection();
SqliteHelper::seedPosts($this->connection);
$this->db = new Database($this->connection);
DB::replaceImmutable($this->db);
}
protected function tearDown(): void
{
DB::replaceImmutable(null);
parent::tearDown();
}
}