Skip to content

Commit 98178a1

Browse files
authored
Merge pull request #6867 from paulbalandan/fix-create-database-test
Fix CreateDatabaseTest to not leave database
2 parents d57c816 + f9c6a6d commit 98178a1

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

tests/system/Commands/CreateDatabaseTest.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,33 @@ final class CreateDatabaseTest extends CIUnitTestCase
3131

3232
protected function setUp(): void
3333
{
34+
parent::setUp();
35+
3436
CITestStreamFilter::$buffer = '';
3537

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

40-
parent::setUp();
42+
$this->dropDatabase();
43+
}
44+
45+
protected function tearDown(): void
46+
{
47+
parent::tearDown();
48+
49+
stream_filter_remove($this->streamFilter);
50+
51+
$this->dropDatabase();
52+
}
53+
54+
protected function getBuffer()
55+
{
56+
return CITestStreamFilter::$buffer;
57+
}
4158

59+
private function dropDatabase(): void
60+
{
4261
if ($this->connection instanceof SQLite3Connection) {
4362
$file = WRITEPATH . 'foobar.db';
4463
if (is_file($file)) {
@@ -53,18 +72,6 @@ protected function setUp(): void
5372
}
5473
}
5574

56-
protected function tearDown(): void
57-
{
58-
stream_filter_remove($this->streamFilter);
59-
60-
parent::tearDown();
61-
}
62-
63-
protected function getBuffer()
64-
{
65-
return CITestStreamFilter::$buffer;
66-
}
67-
6875
public function testCreateDatabase()
6976
{
7077
if ($this->connection instanceof OCI8Connection) {

0 commit comments

Comments
 (0)