From 41f0ed87e14ccd270e3ada4a4f8becbc12619626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Wed, 2 Aug 2017 01:45:35 +0200 Subject: [PATCH] Adding verbose output back to the OrmCacheShell --- src/ORM/OrmCache.php | 8 ++++---- src/Shell/OrmCacheShell.php | 12 ++++++++++-- tests/TestCase/Shell/OrmCacheShellTest.php | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ORM/OrmCache.php b/src/ORM/OrmCache.php index a991c53897d..3c1ab68d5e8 100644 --- a/src/ORM/OrmCache.php +++ b/src/ORM/OrmCache.php @@ -49,7 +49,7 @@ public function __construct($connection) * Build metadata. * * @param string|null $name The name of the table to build cache data for. - * @return bool + * @return array Returns a list build table caches */ public function build($name = null) { @@ -62,14 +62,14 @@ public function build($name = null) $this->_schema->describe($table, ['forceRefresh' => true]); } - return true; + return $tables; } /** * Clear metadata. * * @param string|null $name The name of the table to clear cache data for. - * @return bool + * @return array Returns a list of cleared table caches */ public function clear($name = null) { @@ -84,7 +84,7 @@ public function clear($name = null) Cache::delete($key, $configName); } - return true; + return $tables; } /** diff --git a/src/Shell/OrmCacheShell.php b/src/Shell/OrmCacheShell.php index 21d7553026a..40d22380135 100644 --- a/src/Shell/OrmCacheShell.php +++ b/src/Shell/OrmCacheShell.php @@ -46,7 +46,11 @@ class OrmCacheShell extends Shell public function build($name = null) { $cache = $this->_getOrmCache(); - $cache->build($name); + $tables = $cache->build($name); + + foreach ($tables as $table) { + $this->verbose(sprintf('Cached "%s"', $table)); + } $this->out('Cache build complete'); @@ -62,7 +66,11 @@ public function build($name = null) public function clear($name = null) { $cache = $this->_getOrmCache(); - $cache->clear($name); + $tables = $cache->clear($name); + + foreach ($tables as $table) { + $this->verbose(sprintf('Cleared "%s"', $table)); + } $this->out('Cache clear complete'); diff --git a/tests/TestCase/Shell/OrmCacheShellTest.php b/tests/TestCase/Shell/OrmCacheShellTest.php index 727f6b8cb5a..43c268eab06 100644 --- a/tests/TestCase/Shell/OrmCacheShellTest.php +++ b/tests/TestCase/Shell/OrmCacheShellTest.php @@ -47,7 +47,7 @@ public function setUp() $this->cache->expects($this->any()) ->method('init') ->will($this->returnValue(true)); - Cache::getConfig('orm_cache', $this->cache); + Cache::setConfig('orm_cache', $this->cache); $ds = ConnectionManager::get('test'); $ds->cacheMetadata('orm_cache');