From 06d7a1f0c6ab6c6bd878bbe9f7cab3dbdb3e2a53 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Mon, 30 Oct 2017 20:34:31 +0200 Subject: [PATCH] Improved ConnectionTest performance Methods testMastersShuffled and testMastersSequential executed about 30 seconds each. This commit reduces execution time to 2-5 seconds each. --- tests/framework/db/sqlite/ConnectionTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/framework/db/sqlite/ConnectionTest.php b/tests/framework/db/sqlite/ConnectionTest.php index 8a8e00f..07c28ab 100644 --- a/tests/framework/db/sqlite/ConnectionTest.php +++ b/tests/framework/db/sqlite/ConnectionTest.php @@ -117,6 +117,9 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest $hit_slaves[$db->getSlave()->dsn] = true; $hit_masters[$db->getMaster()->dsn] = true; + if (count($hit_slaves) === $slavesCount && count($hit_masters) === $mastersCount) { + break; + } } $this->assertCount($mastersCount, $hit_masters, 'all masters hit'); @@ -139,6 +142,9 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest $hit_slaves[$db->getSlave()->dsn] = true; $hit_masters[$db->getMaster()->dsn] = true; + if (count($hit_slaves) === $slavesCount) { + break; + } } $this->assertCount(1, $hit_masters, 'same master hit');