From 9404e9991e5f19217ce5027db5e03863bfc7adb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 28 Jan 2023 16:56:18 +0100 Subject: [PATCH] Update test suite and report failed assertions --- .github/workflows/ci.yml | 23 ++++++++++++----------- composer.json | 4 ++-- phpunit.xml.dist | 10 ++++++++-- phpunit.xml.legacy | 8 +++++++- src/Io/Connection.php | 2 +- src/Io/Parser.php | 4 ++-- src/Io/QueryStream.php | 2 -- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aa1354..99f82ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: jobs: PHPUnit: name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: php: @@ -23,30 +23,31 @@ jobs: - 5.5 - 5.4 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug + ini-file: development - run: composer install - run: docker run -d --name mysql --net=host -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test mysql:5 - run: bash tests/wait-for-mysql.sh - - run: MYSQL_USER=test MYSQL_PASSWORD=test vendor/bin/phpunit --coverage-text + - run: vendor/bin/phpunit --coverage-text if: ${{ matrix.php >= 7.3 }} - - run: MYSQL_USER=test MYSQL_PASSWORD=test vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy if: ${{ matrix.php < 7.3 }} PHPUnit-hhvm: name: PHPUnit (HHVM) - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 continue-on-error: true steps: - - uses: actions/checkout@v2 - - uses: azjezz/setup-hhvm@v1 + - uses: actions/checkout@v3 + - run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM + - name: Run hhvm composer.phar install + uses: docker://hhvm/hhvm:3.30-lts-latest with: - version: lts-3.30 - - run: composer self-update --2.2 # downgrade Composer for HHVM - - run: hhvm $(which composer) require phpunit/phpunit:^5 --dev --no-interaction + args: hhvm composer.phar install - run: docker run -d --name mysql --net=host -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test mysql:5 - run: bash tests/wait-for-mysql.sh - - run: MYSQL_USER=test MYSQL_PASSWORD=test hhvm vendor/bin/phpunit + - run: docker run -i --rm --workdir=/data -v "$(pwd):/data" --net=host hhvm/hhvm:3.30-lts-latest hhvm vendor/bin/phpunit diff --git a/composer.json b/composer.json index 009c34c..8ab2633 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ "react/socket": "^1.12" }, "require-dev": { - "react/async": "^4 || ^3 || ^2", - "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.35", + "react/async": "^4 || ^3 || ^2" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index eadec74..23ebd3b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,8 +1,8 @@ - + + + + + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy index cc2a130..711b2cf 100644 --- a/phpunit.xml.legacy +++ b/phpunit.xml.legacy @@ -1,6 +1,6 @@ - + + + + + + + diff --git a/src/Io/Connection.php b/src/Io/Connection.php index 4b0f927..c04d565 100644 --- a/src/Io/Connection.php +++ b/src/Io/Connection.php @@ -81,7 +81,7 @@ public function query($sql, array $params = []) }); $command->on('end', function () use ($command, $deferred, &$rows) { $result = new QueryResult(); - $result->resultFields = $command->resultFields; + $result->resultFields = $command->fields; $result->resultRows = $rows; $result->warningCount = $command->warningCount; diff --git a/src/Io/Parser.php b/src/Io/Parser.php index 7c07b4a..2d6613e 100644 --- a/src/Io/Parser.php +++ b/src/Io/Parser.php @@ -337,7 +337,8 @@ protected function onResultDone() $command = $this->currCommand; $this->currCommand = null; - $command->resultFields = $this->resultFields; + assert($command instanceof QueryCommand); + $command->fields = $this->resultFields; $command->emit('end'); $this->rsState = self::RS_STATE_HEADER; @@ -353,7 +354,6 @@ protected function onSuccess() $command->affectedRows = $this->affectedRows; $command->insertId = $this->insertId; $command->warningCount = $this->warningCount; - $command->message = $this->message; } $command->emit('success'); } diff --git a/src/Io/QueryStream.php b/src/Io/QueryStream.php index 2940a44..1b95734 100644 --- a/src/Io/QueryStream.php +++ b/src/Io/QueryStream.php @@ -15,7 +15,6 @@ */ class QueryStream extends EventEmitter implements ReadableStreamInterface { - private $query; private $connection; private $started = false; private $closed = false; @@ -23,7 +22,6 @@ class QueryStream extends EventEmitter implements ReadableStreamInterface public function __construct(QueryCommand $command, ConnectionInterface $connection) { - $this->command = $command; $this->connection = $connection; // forward result set rows until result set end