Skip to content

Commit a13dbbb

Browse files
authored
Merge pull request #170 from clue-labs/update-tests
Update test suite and report failed assertions
2 parents 89067b2 + 9404e99 commit a13dbbb

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
PHPUnit:
99
name: PHPUnit (PHP ${{ matrix.php }})
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
strategy:
1212
matrix:
1313
php:
@@ -23,30 +23,31 @@ jobs:
2323
- 5.5
2424
- 5.4
2525
steps:
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
- uses: shivammathur/setup-php@v2
2828
with:
2929
php-version: ${{ matrix.php }}
3030
coverage: xdebug
31+
ini-file: development
3132
- run: composer install
3233
- 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
3334
- run: bash tests/wait-for-mysql.sh
34-
- run: MYSQL_USER=test MYSQL_PASSWORD=test vendor/bin/phpunit --coverage-text
35+
- run: vendor/bin/phpunit --coverage-text
3536
if: ${{ matrix.php >= 7.3 }}
36-
- run: MYSQL_USER=test MYSQL_PASSWORD=test vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
37+
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
3738
if: ${{ matrix.php < 7.3 }}
3839

3940
PHPUnit-hhvm:
4041
name: PHPUnit (HHVM)
41-
runs-on: ubuntu-18.04
42+
runs-on: ubuntu-22.04
4243
continue-on-error: true
4344
steps:
44-
- uses: actions/checkout@v2
45-
- uses: azjezz/setup-hhvm@v1
45+
- uses: actions/checkout@v3
46+
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
47+
- name: Run hhvm composer.phar install
48+
uses: docker://hhvm/hhvm:3.30-lts-latest
4649
with:
47-
version: lts-3.30
48-
- run: composer self-update --2.2 # downgrade Composer for HHVM
49-
- run: hhvm $(which composer) require phpunit/phpunit:^5 --dev --no-interaction
50+
args: hhvm composer.phar install
5051
- 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
5152
- run: bash tests/wait-for-mysql.sh
52-
- run: MYSQL_USER=test MYSQL_PASSWORD=test hhvm vendor/bin/phpunit
53+
- run: docker run -i --rm --workdir=/data -v "$(pwd):/data" --net=host hhvm/hhvm:3.30-lts-latest hhvm vendor/bin/phpunit

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"react/socket": "^1.12"
1414
},
1515
"require-dev": {
16-
"react/async": "^4 || ^3 || ^2",
17-
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
16+
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.35",
17+
"react/async": "^4 || ^3 || ^2"
1818
},
1919
"autoload": {
2020
"psr-4": {

phpunit.xml.dist

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
3+
<!-- PHPUnit configuration file with new format for PHPUnit 9.6+ -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
77
cacheResult="false"
88
colors="true"
@@ -23,5 +23,11 @@
2323
<env name="DB_USER" value="test"/>
2424
<env name="DB_PASSWD" value="test"/>
2525
<env name="DB_DBNAME" value="test"/>
26+
<ini name="error_reporting" value="-1" />
27+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
28+
<!-- <ini name="zend.assertions" value="1" /> -->
29+
<ini name="assert.active" value="1" />
30+
<ini name="assert.exception" value="1" />
31+
<ini name="assert.bail" value="0" />
2632
</php>
2733
</phpunit>

phpunit.xml.legacy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
3+
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
@@ -21,5 +21,11 @@
2121
<env name="DB_USER" value="test"/>
2222
<env name="DB_PASSWD" value="test"/>
2323
<env name="DB_DBNAME" value="test"/>
24+
<ini name="error_reporting" value="-1" />
25+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
26+
<!-- <ini name="zend.assertions" value="1" /> -->
27+
<ini name="assert.active" value="1" />
28+
<ini name="assert.exception" value="1" />
29+
<ini name="assert.bail" value="0" />
2430
</php>
2531
</phpunit>

src/Io/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function query($sql, array $params = [])
8181
});
8282
$command->on('end', function () use ($command, $deferred, &$rows) {
8383
$result = new QueryResult();
84-
$result->resultFields = $command->resultFields;
84+
$result->resultFields = $command->fields;
8585
$result->resultRows = $rows;
8686
$result->warningCount = $command->warningCount;
8787

src/Io/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,8 @@ protected function onResultDone()
337337
$command = $this->currCommand;
338338
$this->currCommand = null;
339339

340-
$command->resultFields = $this->resultFields;
340+
assert($command instanceof QueryCommand);
341+
$command->fields = $this->resultFields;
341342
$command->emit('end');
342343

343344
$this->rsState = self::RS_STATE_HEADER;
@@ -353,7 +354,6 @@ protected function onSuccess()
353354
$command->affectedRows = $this->affectedRows;
354355
$command->insertId = $this->insertId;
355356
$command->warningCount = $this->warningCount;
356-
$command->message = $this->message;
357357
}
358358
$command->emit('success');
359359
}

src/Io/QueryStream.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@
1515
*/
1616
class QueryStream extends EventEmitter implements ReadableStreamInterface
1717
{
18-
private $query;
1918
private $connection;
2019
private $started = false;
2120
private $closed = false;
2221
private $paused = false;
2322

2423
public function __construct(QueryCommand $command, ConnectionInterface $connection)
2524
{
26-
$this->command = $command;
2725
$this->connection = $connection;
2826

2927
// forward result set rows until result set end

0 commit comments

Comments
 (0)