szurubooru/tests/AbstractDatabaseTestCase.php

33 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Szurubooru\Tests;
2014-09-01 20:51:59 +02:00
abstract class AbstractDatabaseTestCase extends \Szurubooru\Tests\AbstractTestCase
{
2014-08-30 17:10:45 +02:00
protected $databaseConnection;
public function setUp()
{
2014-09-14 16:16:15 +02:00
parent::setUp();
$config = $this->mockConfig($this->createTestDirectory());
$config->set('database/dsn', 'sqlite::memory:');
2014-09-28 16:26:44 +02:00
$config->set('database/user', '');
$config->set('database/password', '');
2014-09-14 16:16:15 +02:00
$fileServiceMock = $this->mock(\Szurubooru\Services\FileService::class);
2014-08-30 17:10:45 +02:00
$this->databaseConnection = new \Szurubooru\DatabaseConnection($config);
\Szurubooru\Injector::set(\Szurubooru\DatabaseConnection::class, $this->databaseConnection);
\Szurubooru\Injector::set(\Szurubooru\Services\FileService::class, $fileServiceMock);
2014-09-14 16:16:15 +02:00
$upgradeRepository = \Szurubooru\Injector::get(\Szurubooru\Upgrades\UpgradeRepository::class);
$upgradeService = new \Szurubooru\Services\UpgradeService($config, $this->databaseConnection, $upgradeRepository);
$upgradeService->runUpgradesQuiet();
}
public function tearDown()
{
2014-09-14 16:16:15 +02:00
parent::tearDown();
if ($this->databaseConnection)
$this->databaseConnection->close();
}
}