Skip to content

Commit d02750e

Browse files
committed
Improving test performance
Improving tests performance by using cache. In the process, I fixed a SQL subquery cache related bug.
1 parent bf2e068 commit d02750e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/QueryFactory/FindObjectsQueryFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ protected function compute(): void
3737
[
3838
$this->magicSql,
3939
$this->magicSqlCount,
40-
$this->columnDescList
40+
$this->columnDescList,
41+
$this->magicSqlSubQuery
4142
] = $this->cache->fetch($key);
4243
return;
4344
}
@@ -79,6 +80,7 @@ protected function compute(): void
7980
$this->magicSql,
8081
$this->magicSqlCount,
8182
$this->columnDescList,
83+
$this->magicSqlSubQuery
8284
]);
8385
}
8486
}

tests/TDBMAbstractServiceTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ abstract class TDBMAbstractServiceTest extends TestCase
7070
/**
7171
* @var ArrayCache
7272
*/
73-
private $cache;
73+
private static $cache;
7474

7575
public static function setUpBeforeClass(): void
7676
{
7777
self::resetConnection();
7878

79+
self::$cache = new ArrayCache();
80+
7981
$dbConnection = ConnectionFactory::resetDatabase(
8082
$GLOBALS['db_driver'],
8183
$GLOBALS['db_host'] ?? null,
@@ -134,10 +136,7 @@ protected function getDummyGeneratorListener() : DummyGeneratorListener
134136

135137
protected function getCache(): ArrayCache
136138
{
137-
if ($this->cache === null) {
138-
$this->cache = new ArrayCache();
139-
}
140-
return $this->cache;
139+
return self::$cache;
141140
}
142141

143142
protected function getConfiguration() : ConfigurationInterface

0 commit comments

Comments
 (0)