Skip to content
Draft
Show file tree
Hide file tree
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
28 changes: 4 additions & 24 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
schedule:
- cron: '0 0/2 * * *'
workflow_dispatch:

jobs:
smoke-test:
Expand Down Expand Up @@ -83,13 +84,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
type: ['Phpunit', 'Phpunit Lowest']
include:
- php: 'latest'
type: 'Phpunit Burn'
env:
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.4' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == '8.5' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
services:
mysql:
image: mysql:${{ matrix.type == 'Phpunit Lowest' && 'latest' || '8.0' }}
Expand All @@ -107,11 +108,6 @@ jobs:
POSTGRES_PASSWORD: atk4_pass
POSTGRES_DB: atk4_test
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mssql:
image: mcr.microsoft.com/mssql/server:${{ matrix.type == 'Phpunit Lowest' && 'latest' || '2017-latest' }}
env:
ACCEPT_EULA: Y
SA_PASSWORD: atk4_pass
oracle:
image: gvenzl/${{ matrix.type == 'Phpunit Lowest' && 'oracle-free:slim-faststart' || 'oracle-xe:18-slim-faststart' }}
env:
Expand Down Expand Up @@ -145,6 +141,7 @@ jobs:
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* --dev; fi
if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-install phpunit/phpcov; fi
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
if [ "${{ matrix.type }}" = "Phpunit Lowest" ] && [ "${{ matrix.php >= 8.5 }}" != "false" ]; then composer require --no-interaction --no-update phpunit/phpunit:^11.3 --dev; fi
if [ "${{ matrix.type }}" = "Phpunit Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader; fi
if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~public function runBare(): void~public function runBare(): void { gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 64; else echo 4; fi)"', 0); $emitter = Event\\Facade::emitter(); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); if ($this->inIsolation) { $dispatcher = \\Closure::bind(static fn () => $emitter->dispatcher, null, Event\\DispatchingEmitter::class)(); if ($i === -1) { $dispatcherEvents = $dispatcher->flush()->asArray(); } else { $dispatcher->flush(); } foreach ($dispatcherEvents as $event) { $dispatcher->dispatch($event); } } gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $e = new AssertionFailedError("Memory leak detected! (" . implode(" + ", array_map(static fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)"); $this->status = TestStatus::failure($e->getMessage()); $emitter->testFailed($this->valueObjectForEvents(), Event\\Code\\ThrowableBuilder::from($e), Event\\Code\\ComparisonFailureBuilder::from($e)); $this->onNotSuccessfulTest($e); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi

Expand All @@ -162,13 +159,6 @@ jobs:
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi)
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-sqlite.cov; fi

- name: "Run tests: SQLite 3.25.3"
if: success() || failure()
run: |
apk add sqlite-dev=3.25.3-r0 --repository=https://dl-cdn.alpinelinux.org/alpine/v3.6/main
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi)
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-sqlite325.cov; fi

# remove once SQLite v3.46.0 or higher is available in stable Alpine release
# TODO https://github.com/atk4/data/blob/df7dbb9136/tests/ScopeTest.php#L334
- name: "Run tests: SQLite edge"
Expand Down Expand Up @@ -228,16 +218,6 @@ jobs:
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi)
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-postgres.cov; fi

- name: "Run tests: MSSQL"
if: success() || failure()
env:
DB_DSN: "sqlsrv:host=mssql;dbname=master;driverOptions[TrustServerCertificate]=1"
DB_USER: sa
DB_PASSWORD: atk4_pass
run: |
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi)
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mssql.cov; fi

- name: "Run tests: Oracle - PDO (only for coverage or cron)"
if: (success() || failure()) && (env.LOG_COVERAGE || github.event_name == 'schedule')
env:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
],
"homepage": "https://github.com/atk4/data",
"require": {
"php": ">=7.4 <8.5",
"php": ">=7.4 <8.6",
"atk4/core": "dev-develop",
"doctrine/dbal": "~3.5.1 || ~3.6.0 || ~3.7.0 || ~3.8.0 || ~3.9.0 || ~3.10.0 || ~4.0.0 || ~4.1.0 || ~4.2.0 || ~4.3.0 || ~4.4.0",
"mvorisek/atk4-hintable": "~1.9.0",
"symfony/polyfill-intl-idn": "^1.30"
},
"require-release": {
"php": ">=7.4 <8.5",
"php": ">=7.4 <8.6",
"atk4/core": "~6.1.0",
"doctrine/dbal": "~3.5.1 || ~3.6.0 || ~3.7.0 || ~3.8.0 || ~3.9.0 || ~3.10.0 || ~4.0.0 || ~4.1.0 || ~4.2.0 || ~4.3.0 || ~4.4.0",
"mvorisek/atk4-hintable": "~1.9.0",
Expand Down
6 changes: 6 additions & 0 deletions src/Persistence/Sql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@
(static::class)::createDbalConfiguration()
);

// backport https://github.com/doctrine/dbal/pull/7173
// TODO remove once DBAL 3.10+ is supported
if (\PHP_VERSION_ID >= 8_05_00 && ($dsn['driver'] === 'pdo_mysql' || $dsn['driver'] === 'mysqli')) {
@$dbalConnection->getWrappedConnection(); // @phpstan-ignore method.deprecated (https://github.com/doctrine/dbal/issues/5199)

Check failure on line 287 in src/Persistence/Sql/Connection.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

No error with identifier method.deprecated is reported on line 287.

Check failure on line 287 in src/Persistence/Sql/Connection.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Call to an undefined method Doctrine\DBAL\Connection::getWrappedConnection().

Check failure on line 287 in src/Persistence/Sql/Connection.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

No error with identifier method.deprecated is reported on line 287.

Check failure on line 287 in src/Persistence/Sql/Connection.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Call to an undefined method Doctrine\DBAL\Connection::getWrappedConnection().
}

return self::isDbal3x()
? $dbalConnection->getWrappedConnection() // @phpstan-ignore method.notFound
: \Closure::bind(static fn () => $dbalConnection->connect(), null, DbalConnection::class)();
Expand Down
6 changes: 3 additions & 3 deletions src/Persistence/Sql/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ static function ($matches) use ($params, &$numParams, &$i, &$j) {
protected function _executeStatement(Statement $statement, bool $fromExecuteStatement)
{
if ($fromExecuteStatement) {
$result = $statement->executeStatement();
$result = @$statement->executeStatement();
} else {
$result = $statement->executeQuery();
$result = @$statement->executeQuery();
}

return $result;
Expand Down Expand Up @@ -590,7 +590,7 @@ protected function _execute(?object $connection, bool $fromExecuteStatement)

$platform = $this->connection->getDatabasePlatform();
try {
$statement = $connection->prepare($sql);
$statement = @$connection->prepare($sql);

foreach ($params as $key => $val) {
if ($val === null) {
Expand Down
10 changes: 5 additions & 5 deletions src/Schema/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function getCreatedTableNames(): array

public function create(): self
{
$this->createSchemaManager()->createTable($this->table);
@$this->createSchemaManager()->createTable($this->table);
$this->createdTableNames[] = $this->table->getName();

return $this;
Expand Down Expand Up @@ -184,7 +184,7 @@ public function drop(bool $dropForeignKeysFirst = false): self
}
}

$schemaManager->dropTable($this->table->getQuotedName($this->getDatabasePlatform()));
@$schemaManager->dropTable($this->table->getQuotedName($this->getDatabasePlatform()));

$this->createdTableNames = array_values(array_diff($this->createdTableNames, [$this->table->getName()]));

Expand Down Expand Up @@ -407,7 +407,7 @@ public function isTableExists(string $tableName): bool
->field($this->getConnection()->expr('1'))
->table($tableName)
->render();
$this->getConnection()->getConnection()->executeQuery($sql);
@$this->getConnection()->getConnection()->executeQuery($sql);

return true;
} catch (TableNotFoundException $e) {
Expand Down Expand Up @@ -549,7 +549,7 @@ public function createIndex(array $fields, bool $isUnique): void
$mssqlNullable === false ? ['atk4-not-null'] : []
);

$this->createSchemaManager()->createIndex($index, $platform->quoteIdentifier($tableName));
@$this->createSchemaManager()->createIndex($index, $platform->quoteIdentifier($tableName));
}

/**
Expand Down Expand Up @@ -594,6 +594,6 @@ public function createForeignKey($relation): void
$foreignTableIdentifier = $this->fixAbstractAssetName(new Identifier('0.0'), $foreignField->getOwner()->table);
\Closure::bind(static fn () => $foreignKey->_foreignTableName = $foreignTableIdentifier, null, ForeignKeyConstraint::class)();

$this->createSchemaManager()->createForeignKey($foreignKey, $platform->quoteIdentifier($localField->getOwner()->table));
@$this->createSchemaManager()->createForeignKey($foreignKey, $platform->quoteIdentifier($localField->getOwner()->table));
}
}
Loading