diff --git a/.gitattributes b/.gitattributes index d41c778..d9f4a3b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ .gitignore export-ignore /test export-ignore /phpunit.xml.dist export-ignore +/phpcs.xml.dist export-ignore diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1596c12..2e7ae1a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,10 +12,11 @@ jobs: strategy: matrix: - php-versions: ['7.3', '7.4', '8.0'] - name: PHP ${{ matrix.php-versions }} + php-versions: ['8.3', '8.4'] + dbal: ['3.*', '4.*'] + name: PHP ${{ matrix.php-versions }}, DBAL ${{ matrix.dbal }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} @@ -26,10 +27,10 @@ jobs: - uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-${{ matrix.dbal }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.dbal }}- - name: composer install - run: composer install --no-progress --prefer-dist --optimize-autoloader + run: composer require --dev doctrine/dbal:"${{ matrix.dbal }}" --no-progress --prefer-dist --optimize-autoloader - run: sudo /etc/init.d/mysql start - name: phpunit run: php vendor/bin/phpunit diff --git a/bin/mysql_github.sh b/bin/mysql_github.sh index 027fff8..d12d7e3 100755 --- a/bin/mysql_github.sh +++ b/bin/mysql_github.sh @@ -15,7 +15,7 @@ finish() { DBNAME="$(date +%s%N)" echo "CREATE DATABASE \`$DBNAME\`;" | $MYSQL >&3 -# PHP 7.3 compatibility, does not support caching_sha2_password, use mysql_native_password on a new user instead. +# Older PHP/mysql clients do not support caching_sha2_password, use mysql_native_password on a new user instead. echo "CREATE USER IF NOT EXISTS 'test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';" | $MYSQL >&3 echo "GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';" | $MYSQL >&3 echo "FLUSH PRIVILEGES;" | $MYSQL >&3 diff --git a/composer.json b/composer.json index 2ee5659..16dde04 100644 --- a/composer.json +++ b/composer.json @@ -4,10 +4,10 @@ "description": "Provide a real database, safe for testing purposes", "license": "MIT", "require": { - "php": "^7.3|^8.0", - "doctrine/orm": "^2.5.4" + "php": "^8.3" }, "require-dev": { + "doctrine/dbal": "^3.7|^4.0", "hostnet/phpcs-tool": "^9.1.0", "phpunit/phpunit": "^9.4" }, diff --git a/test/MysqlPersistentConnectionTest.php b/test/MysqlPersistentConnectionTest.php index 3ce4668..e48139b 100644 --- a/test/MysqlPersistentConnectionTest.php +++ b/test/MysqlPersistentConnectionTest.php @@ -7,6 +7,7 @@ namespace Hostnet\Component\DatabaseTest; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Tools\DsnParser; use PHPUnit\Framework\TestCase; /** @@ -22,7 +23,7 @@ public function testConstruction(): void $connection = new MysqlPersistentConnection(); $url = $connection->getConnectionUrl(); - $this->assertCount(1, $this->listDatabases(['url' => $url])); + $this->assertCount(1, $this->listDatabases((new DsnParser(['mysql' => 'pdo_mysql']))->parse($url))); } /** @@ -55,13 +56,12 @@ public function testDestruction(): void * * @param string[] $params Doctrine connection parameters * @return string[] - * @throws \Doctrine\DBAL\DBALException + * @throws \Doctrine\DBAL\Exception */ private function listDatabases(array $params): array { - $doctrine = DriverManager::getConnection($params); - $statement = $doctrine->executeQuery('SHOW DATABASES'); - $data = $statement->fetchAll(\PDO::FETCH_COLUMN); + $doctrine = DriverManager::getConnection($params); + $data = $doctrine->executeQuery('SHOW DATABASES')->fetchFirstColumn(); return array_filter( $data,