Skip to content

Commit 058f8bb

Browse files
Fix test enable query log (#203)
1 parent 9607e5f commit 058f8bb

5 files changed

Lines changed: 28 additions & 11 deletions

File tree

.github/workflows/build.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
env:
1212
COMPOSER_ROOT_VERSION: "dev-master"
13-
extensions: dom, json, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite, pdo_sqlsrv-5.9.0preview1
13+
extensions: dom, json, pdo, pdo_mysql, pdo_oci, pdo_pgsql, pdo_sqlite, pdo_sqlsrv-5.9.0preview1, oci8
1414
key: cache-v1
1515

1616
runs-on: ${{ matrix.os }}
@@ -33,6 +33,11 @@ jobs:
3333
ports:
3434
- 3306:3306
3535
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
36+
oci:
37+
image: wnameless/oracle-xe-11g-r2:latest
38+
ports:
39+
- 1521:1521
40+
options: --name=oci
3641
postgres:
3742
image: postgres:13
3843
env:

.scrutinizer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ filter:
66
- "src/*"
77

88
tools:
9-
php_code_coverage:
10-
enabled: true
9+
external_code_coverage:
10+
timeout: 660
1111

1212
build:
1313
nodes:

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"Yiisoft\\ActiveRecord\\Tests\\": "vendor/yiisoft/active-record/tests",
5858
"Yiisoft\\Db\\Mssql\\Tests\\": "vendor/yiisoft/db-mssql/tests",
5959
"Yiisoft\\Db\\Mysql\\Tests\\": "vendor/yiisoft/db-mysql/tests",
60+
"Yiisoft\\Db\\Oracle\\Tests\\": "vendor/yiisoft/db-oracle/tests",
6061
"Yiisoft\\Db\\Pgsql\\Tests\\": "vendor/yiisoft/db-pgsql/tests",
6162
"Yiisoft\\Db\\Sqlite\\Tests\\": "vendor/yiisoft/db-sqlite/tests"
6263
}

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<testsuite name="Mysql">
2323
<directory>./vendor/yiisoft/db-mysql/tests</directory>
2424
</testsuite>
25+
<testsuite name="Oracle">
26+
<directory>./vendor/yiisoft/db-oracle/tests</directory>
27+
</testsuite>
2528
<testsuite name="Pgsql">
2629
<directory>./vendor/yiisoft/db-pgsql/tests</directory>
2730
</testsuite>

src/TestUtility/TestConnectionTrait.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public function testEnableQueryLog(): void
194194

195195
$db->createCommand()->createTable('qlog1', ['id' => 'pk'])->execute();
196196

197-
$this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
197+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
198+
$this->assertCount(1, $message->all());
198199
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
199200
$this->assertNotNull($db->getTableSchema('qlog1', true));
200201

@@ -203,7 +204,8 @@ public function testEnableQueryLog(): void
203204

204205
$db->createCommand('SELECT * FROM {{qlog1}}')->queryAll();
205206

206-
$this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
207+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
208+
$this->assertCount(1, $message->all());
207209
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
208210

209211
/* profiling only */
@@ -215,7 +217,8 @@ public function testEnableQueryLog(): void
215217

216218
$db->createCommand()->createTable('qlog2', ['id' => 'pk'])->execute();
217219

218-
$this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
220+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
221+
$this->assertCount(0, $message->all());
219222
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
220223
$this->assertNotNull($db->getTableSchema('qlog2', true));
221224

@@ -224,7 +227,8 @@ public function testEnableQueryLog(): void
224227

225228
$db->createCommand('SELECT * FROM {{qlog2}}')->queryAll();
226229

227-
$this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
230+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
231+
$this->assertCount(0, $message->all());
228232
$this->assertCount(1, $this->getInaccessibleProperty($this->profiler, 'messages'));
229233

230234
/* logging only */
@@ -236,7 +240,8 @@ public function testEnableQueryLog(): void
236240

237241
$db->createCommand()->createTable('qlog3', ['id' => 'pk'])->execute();
238242

239-
$this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
243+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
244+
$this->assertCount(1, $message->all());
240245
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
241246
$this->assertNotNull($db->getTableSchema('qlog3', true));
242247

@@ -245,7 +250,8 @@ public function testEnableQueryLog(): void
245250

246251
$db->createCommand('SELECT * FROM {{qlog3}}')->queryAll();
247252

248-
$this->assertCount(1, $this->getInaccessibleProperty($this->logger, 'messages'));
253+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
254+
$this->assertCount(1, $message->all());
249255
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
250256

251257
/* disabled */
@@ -257,13 +263,15 @@ public function testEnableQueryLog(): void
257263

258264
$db->createCommand()->createTable('qlog4', ['id' => 'pk'])->execute();
259265

266+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
260267
$this->assertNotNull($db->getTableSchema('qlog4', true));
261-
$this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
268+
$this->assertCount(0, $message->all());
262269
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
263270

264271
$db->createCommand('SELECT * FROM {{qlog4}}')->queryAll();
265272

266-
$this->assertCount(0, $this->getInaccessibleProperty($this->logger, 'messages'));
273+
$message = $this->getInaccessibleProperty($this->logger, 'messages');
274+
$this->assertCount(0, $message->all());
267275
$this->assertCount(0, $this->getInaccessibleProperty($this->profiler, 'messages'));
268276
}
269277

0 commit comments

Comments
 (0)