Signed-off-by: Christian Wolf <github@christianwolf.email>
This commit is contained in:
Christian Wolf 2021-08-21 19:51:08 +02:00
Родитель d9b4291077
Коммит c39d301959
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 9FC3120E932F73F1
2 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -19,4 +19,7 @@
<directory suffix=".php">lib</directory>
</include>
</coverage>
<php>
<env name="INPUT_DB" value="unknown" />
</php>
</phpunit>

Просмотреть файл

@ -2,6 +2,7 @@
namespace OCA\Cookbook\tests\Integration\Setup\Migrations;
use Doctrine\DBAL\Schema\Table;
use OCP\IDBConnection;
use OCP\Util;
use OC\DB\Connection;
@ -42,7 +43,6 @@ abstract class AbstractMigrationTestCase extends TestCase {
private const TMP_MIGRATIONS = '/tmp/old-migrations';
public function setUp(): void {
parent::setUp();
resetEnvironmentToBackup('plain');
@ -70,6 +70,11 @@ abstract class AbstractMigrationTestCase extends TestCase {
} else {
$this->connection = $this->db;
}
if ($_ENV['INPUT_DB'] === 'sqlite') {
$this->resetSQLite();
}
$this->migrationService = new MigrationService('cookbook', $this->connection);
$this->assertIsObject($this->migrationService);
@ -108,4 +113,27 @@ abstract class AbstractMigrationTestCase extends TestCase {
private function restoreMigrations() {
exec('mv ' . self::TMP_MIGRATIONS . '/* lib/Migration');
}
private function resetSQLite(): void {
$allTables = $this->schema->getTables();
$tables = array_filter($allTables, function (Table $t) {
return str_starts_with($t->getName(), 'oc_cookbook');
});
/**
* @var Table $t
*/
foreach ($tables as $t) {
$this->schema->dropTable(preg_replace('/^oc_/', '', $t->getName()));
}
$qb = $this->db->getQueryBuilder();
$qb->delete('migrations')->where('app = :app');
$qb->setParameter('app', 'cookbook');
$qb->execute();
$this->schema->performDropTableCalls();
$this->renewSchema();
}
}