Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Apr 30, 2024
1 parent d1de682 commit c0af259
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: phpunit

jobs:
phpunit:
name: "[MySQL] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
name: "[MySQL:${{ matrix.mysql-version }}] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -14,7 +14,7 @@ jobs:
php: [ '8.3' ]
os: [ 'ubuntu-latest' ]
stability: [ 'prefer-stable' ]
mysql-version: [ '5,7', '8.0' ]
mysql-version: [ '5', '8' ]

services:
mysql:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: phpunit

jobs:
phpunit:
name: "[Postgres] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
name: "[Postgres:${{ matrix.pgsql-version }}] PHP 8.3-${{ matrix.os }}, ${{ matrix.stability }}"
runs-on: ${{ matrix.os }}

strategy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public function up(): void

public function down(): void
{
$this->table('events')
->alterColumn('timestamp', 'decimal', ['nullable' => false, 'defaultValue' => null, 'precision' => 10, 'scale' => 5])
->update();

}
}
8 changes: 4 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
<junit outputFile=".cache/phpunit/report.junit.xml"/>
</logging>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory=".cache/coverage"/>
<text outputFile=".cache/coverage.txt"/>
<clover outputFile=".cache/logs/clover.xml"/>
</report>
</coverage>
</phpunit>
18 changes: 11 additions & 7 deletions tests/DatabaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@

abstract class DatabaseTestCase extends TestCase
{
use DatabaseMigrations, RefreshDatabase, Transactions, Helper, DatabaseAsserts, ShowQueries;
use Transactions, Helper, DatabaseAsserts, ShowQueries;

private DriverEnum $dbDriver;

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

$dbDriver = $this->get(DriverEnum::class);
$this->getRefreshStrategy()->enableRefreshAttribute();
$this->dbDriver = $this->get(DriverEnum::class);
// $this->getRefreshStrategy()->enableRefreshAttribute();

// TODO: refactor this
if ($dbDriver === DriverEnum::MongoDb) {
if ($this->dbDriver === DriverEnum::MongoDb) {
$mongoDb = $this->get(Database::class);
foreach ($mongoDb->listCollections() as $collection) {
/** @var CollectionInfo $collection */
$mongoDb->selectCollection($collection->getName())->drop();
}
} elseif ($dbDriver === DriverEnum::InMemory) {
} elseif ($this->dbDriver === DriverEnum::InMemory) {
$this->get(CacheStorageProviderInterface::class)->storage('events')->clear();
$this->get(CacheStorageProviderInterface::class)->storage('projects')->clear();
}
Expand All @@ -50,8 +52,10 @@ protected function tearDown(): void
{
parent::tearDown();

$this->cleanIdentityMap();
$this->getCurrentDatabaseDriver()->disconnect();
if ($this->dbDriver === DriverEnum::Database) {
$this->cleanIdentityMap();
$this->getCurrentDatabaseDriver()->disconnect();
}
}

public function persist(object ...$entity): void
Expand Down

0 comments on commit c0af259

Please sign in to comment.