Skip to content

Fix CreateDatabaseTest to not leave database #6867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions tests/system/Commands/CreateDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,33 @@ final class CreateDatabaseTest extends CIUnitTestCase

protected function setUp(): void
{
parent::setUp();

CITestStreamFilter::$buffer = '';

$this->streamFilter = stream_filter_append(STDOUT, 'CITestStreamFilter');
$this->streamFilter = stream_filter_append(STDERR, 'CITestStreamFilter');
$this->connection = Database::connect();

parent::setUp();
$this->dropDatabase();
}

protected function tearDown(): void
{
parent::tearDown();

stream_filter_remove($this->streamFilter);

$this->dropDatabase();
}

protected function getBuffer()
{
return CITestStreamFilter::$buffer;
}

private function dropDatabase(): void
{
if ($this->connection instanceof SQLite3Connection) {
$file = WRITEPATH . 'foobar.db';
if (is_file($file)) {
Expand All @@ -53,18 +72,6 @@ protected function setUp(): void
}
}

protected function tearDown(): void
{
stream_filter_remove($this->streamFilter);

parent::tearDown();
}

protected function getBuffer()
{
return CITestStreamFilter::$buffer;
}

public function testCreateDatabase()
{
if ($this->connection instanceof OCI8Connection) {
Expand Down