diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2018-12-30 16:19:52 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2018-12-30 16:19:52 +0000 |
| commit | 0115bc1678cafd957052cd2d256563ad3e242cc1 (patch) | |
| tree | ee020fc08dddd2714bb404a71dc0f099cd35ddaf /tests/TestCase.php | |
| parent | b48bb5e9c4e596e98b7c8c27c14b9f19abfffb26 (diff) | |
| download | webtrees-0115bc1678cafd957052cd2d256563ad3e242cc1.tar.gz webtrees-0115bc1678cafd957052cd2d256563ad3e242cc1.tar.bz2 webtrees-0115bc1678cafd957052cd2d256563ad3e242cc1.zip | |
Fix: #2075 typo
Diffstat (limited to 'tests/TestCase.php')
| -rw-r--r-- | tests/TestCase.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/TestCase.php b/tests/TestCase.php index 1136b5b02e..ebdd34c3e0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -17,9 +17,60 @@ declare(strict_types=1); namespace Fisharebest\Webtrees; +use function basename; +use Fisharebest\Webtrees\Schema\SeedDatabase; +use Illuminate\Database\Capsule\Manager as DB; +use function file_get_contents; + /** * Base class for unit tests */ class TestCase extends \PHPUnit\Framework\TestCase { + protected function setUp() + { + parent::setUp(); + + defined('WT_BASE_URL') || define('WT_BASE_URL', 'http://localhost/'); + defined('WT_DATA_DIR') || define('WT_DATA_DIR', 'data/'); + defined('WT_ROOT') || define('WT_ROOT', ''); + I18N::init('en-US'); + } + + /** + * Create an SQLite in-memory database for testing + */ + protected function createTestDatabase(): void + { + $capsule = new DB(); + $capsule->addConnection([ + 'driver' => 'sqlite', + 'database' => ':memory:', + ]); + $capsule->setAsGlobal(); + + // Create tables + Database::updateSchema('\Fisharebest\Webtrees\Schema', 'WT_SCHEMA_VERSION', Webtrees::SCHEMA_VERSION); + + // Create config data + (new SeedDatabase())->run(); + } + + /** + * Import a GEDCOM file into the test database. + * + * @param string $gedcom_file + */ + protected function importTree(string $gedcom_file): void + { + $x = DB::table('gedcom')->insert([ + 'gedcom_name' => basename($gedcom_file), + ]); + + var_dump($x);exit; + + DB::table('gedcom_chunk')->insert([ + 'chunk_data' => file_get_contents($gedcom_file), + ]); + } } |
