From 058f8bb759bd36e7142f4d48d7c902ef70545230 Mon Sep 17 00:00:00 2001
From: Wilmer Arambula <42547589+terabytesoftw@users.noreply.github.com>
Date: Thu, 26 Nov 2020 20:52:17 -0300
Subject: [PATCH] Fix test enable query log (#203)
---
.github/workflows/build.yml | 7 ++++++-
.scrutinizer.yml | 4 ++--
composer.json | 1 +
phpunit.xml.dist | 3 +++
src/TestUtility/TestConnectionTrait.php | 24 ++++++++++++++++--------
5 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6e7dce4da..b8aebbc9c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,7 +10,7 @@ jobs:
env:
COMPOSER_ROOT_VERSION: "dev-master"
- extensions: dom, json, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_sqlsrv-5.9.0preview1
+ extensions: dom, json, pdo, pdo_mysql, pdo_oci, pdo_pgsql, pdo_sqlite, pdo_sqlsrv-5.9.0preview1, oci8
key: cache-v1
runs-on: ${{ matrix.os }}
@@ -33,6 +33,11 @@ jobs:
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
+ oci:
+ image: wnameless/oracle-xe-11g-r2:latest
+ ports:
+ - 1521:1521
+ options: --name=oci
postgres:
image: postgres:13
env:
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index 7ca99bd13..82efda58a 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -6,8 +6,8 @@ filter:
- "src/*"
tools:
- php_code_coverage:
- enabled: true
+ external_code_coverage:
+ timeout: 660
build:
nodes:
diff --git a/composer.json b/composer.json
index a1739b62a..776e1a1c6 100644
--- a/composer.json
+++ b/composer.json
@@ -57,6 +57,7 @@
"Yiisoft\\ActiveRecord\\Tests\\": "vendor/yiisoft/active-record/tests",
"Yiisoft\\Db\\Mssql\\Tests\\": "vendor/yiisoft/db-mssql/tests",
"Yiisoft\\Db\\Mysql\\Tests\\": "vendor/yiisoft/db-mysql/tests",
+ "Yiisoft\\Db\\Oracle\\Tests\\": "vendor/yiisoft/db-oracle/tests",
"Yiisoft\\Db\\Pgsql\\Tests\\": "vendor/yiisoft/db-pgsql/tests",
"Yiisoft\\Db\\Sqlite\\Tests\\": "vendor/yiisoft/db-sqlite/tests"
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 38880ca7f..528ea0392 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -22,6 +22,9 @@
./vendor/yiisoft/db-mysql/tests
+
+ ./vendor/yiisoft/db-oracle/tests
+
./vendor/yiisoft/db-pgsql/tests
diff --git a/src/TestUtility/TestConnectionTrait.php b/src/TestUtility/TestConnectionTrait.php
index 97681935c..6ea6d10e0 100644
--- a/src/TestUtility/TestConnectionTrait.php
+++ b/src/TestUtility/TestConnectionTrait.php
@@ -194,7 +194,8 @@ public function testEnableQueryLog(): void
$db->createCommand()->createTable('qlog1', ['id' => 'pk'])->execute();
- $this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(1, $message->all());
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
$this->assertNotNull($db->getTableSchema('qlog1', true));
@@ -203,7 +204,8 @@ public function testEnableQueryLog(): void
$db->createCommand('SELECT * FROM {{qlog1}}')->queryAll();
- $this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(1, $message->all());
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
/* profiling only */
@@ -215,7 +217,8 @@ public function testEnableQueryLog(): void
$db->createCommand()->createTable('qlog2', ['id' => 'pk'])->execute();
- $this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(0, $message->all());
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
$this->assertNotNull($db->getTableSchema('qlog2', true));
@@ -224,7 +227,8 @@ public function testEnableQueryLog(): void
$db->createCommand('SELECT * FROM {{qlog2}}')->queryAll();
- $this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(0, $message->all());
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
/* logging only */
@@ -236,7 +240,8 @@ public function testEnableQueryLog(): void
$db->createCommand()->createTable('qlog3', ['id' => 'pk'])->execute();
- $this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(1, $message->all());
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
$this->assertNotNull($db->getTableSchema('qlog3', true));
@@ -245,7 +250,8 @@ public function testEnableQueryLog(): void
$db->createCommand('SELECT * FROM {{qlog3}}')->queryAll();
- $this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(1, $message->all());
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
/* disabled */
@@ -257,13 +263,15 @@ public function testEnableQueryLog(): void
$db->createCommand()->createTable('qlog4', ['id' => 'pk'])->execute();
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
$this->assertNotNull($db->getTableSchema('qlog4', true));
- $this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $this->assertCount(0, $message->all());
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
$db->createCommand('SELECT * FROM {{qlog4}}')->queryAll();
- $this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
+ $message = $this->getInaccessibleProperty($this->logger, 'messages');
+ $this->assertCount(0, $message->all());
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
}