Skip to content

Commit

Permalink
test: DatabaseTestCase now always drops DB on tearDown
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jul 4, 2024
1 parent 5021d67 commit 4ed5536
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
17 changes: 0 additions & 17 deletions tests/src/Functional/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

use Cycle\ActiveRecord\Facade;
use Cycle\App\Entity\User;
use Cycle\Database\Database;
use Cycle\Database\DatabaseManager;
use Cycle\ORM\Select\Repository;
use PHPUnit\Framework\Attributes\Test;

Expand Down Expand Up @@ -167,19 +165,4 @@ public function it_gets_default_repository_of_entity(): void

self::assertInstanceOf(Repository::class, $repository);
}

/**
* @throws \Throwable
*/
public function tearDown(): void
{
parent::tearDown();

$databaseManager = $this->getContainer()->get(DatabaseManager::class);
/** @var Database $database */
$database = $databaseManager->database('default');

$this->dropDatabase($database);
Facade::reset();
}
}
17 changes: 17 additions & 0 deletions tests/src/Functional/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace Cycle\Tests\Functional;

use Cycle\ActiveRecord\Facade;
use Cycle\Database\Database;
use Cycle\Database\DatabaseInterface;
use Cycle\Database\DatabaseManager;
use Cycle\Database\Driver\DriverInterface;
use Cycle\Database\Driver\HandlerInterface;
use Cycle\Database\Table;
Expand Down Expand Up @@ -56,6 +58,21 @@ protected function setUp(): void
]);
}

/**
* @throws \Throwable
*/
protected function tearDown(): void
{
parent::tearDown();

$databaseManager = $this->getContainer()->get(DatabaseManager::class);
/** @var Database $database */
$database = $databaseManager->database('default');

$this->dropDatabase($database);
Facade::reset();
}

/**
* @throws \Throwable
*/
Expand Down
18 changes: 0 additions & 18 deletions tests/src/Functional/Query/ActiveQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

namespace Cycle\Tests\Functional\Query;

use Cycle\ActiveRecord\Facade;
use Cycle\App\Entity\User;
use Cycle\Database\Database;
use Cycle\Database\DatabaseManager;
use Cycle\Tests\Functional\DatabaseTestCase;
use PHPUnit\Framework\Attributes\Test;

Expand All @@ -20,19 +17,4 @@ public function it_gets_role_from_query(): void

self::assertSame(User::class, $query->getRole());
}

/**
* @throws \Throwable
*/
public function tearDown(): void
{
parent::tearDown();

$databaseManager = $this->getContainer()->get(DatabaseManager::class);
/** @var Database $database */
$database = $databaseManager->database('default');

$this->dropDatabase($database);
Facade::reset();
}
}

0 comments on commit 4ed5536

Please sign in to comment.