From 9b6eca6d80a4be38562ea31f492a1675f3906ea6 Mon Sep 17 00:00:00 2001 From: Kamil Iskierka Date: Thu, 14 Feb 2019 07:46:21 +0100 Subject: [PATCH 1/4] [WMS-1703] Create PHPArray adapter to cache-factory library --- src/Factory/Adapter/PHPArray.php | 28 +++++++++++++++++++++++++ src/Factory/Config/Adapter/PHPArray.php | 19 +++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/Factory/Adapter/PHPArray.php create mode 100644 src/Factory/Config/Adapter/PHPArray.php diff --git a/src/Factory/Adapter/PHPArray.php b/src/Factory/Adapter/PHPArray.php new file mode 100644 index 0000000..f975a01 --- /dev/null +++ b/src/Factory/Adapter/PHPArray.php @@ -0,0 +1,28 @@ +root($this->getAdapterName()); + + return $node; + } +} From c5ad2810420b27550a4eae8fedab6a1cc4a521d5 Mon Sep 17 00:00:00 2001 From: Kamil Iskierka Date: Tue, 26 Feb 2019 11:38:51 +0100 Subject: [PATCH 2/4] [WMS-1703] Repaired current test --- tests/FactoryTests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FactoryTests.php b/tests/FactoryTests.php index 368de26..c86a577 100644 --- a/tests/FactoryTests.php +++ b/tests/FactoryTests.php @@ -90,7 +90,7 @@ public function testThatFactoryWorksWithValidConfig(array $config) $taggableCachePool = $cachePoolFactory->makeTaggable($this->adapterName); $this->assertInstanceOf('Psr\\Cache\\CacheItemPoolInterface', $cachePool); - $this->assertInstanceOf('Cache\\Taggable\\TaggablePoolInterface', $taggableCachePool); + $this->assertInstanceOf('Cache\\TagInterop\\TaggableCacheItemPoolInterface', $taggableCachePool); } /** From e39c99178f957e5cd69ddac9129e5d0cf4b5eb5c Mon Sep 17 00:00:00 2001 From: Kamil Iskierka Date: Tue, 26 Feb 2019 12:27:13 +0100 Subject: [PATCH 3/4] [WMS-1703] Unit test added --- tests/Adapter/PHPArrayAdapterTests.php | 58 ++++++++++++++++++++++++++ tests/cache.yml | 2 + 2 files changed, 60 insertions(+) create mode 100644 tests/Adapter/PHPArrayAdapterTests.php diff --git a/tests/Adapter/PHPArrayAdapterTests.php b/tests/Adapter/PHPArrayAdapterTests.php new file mode 100644 index 0000000..7202bc4 --- /dev/null +++ b/tests/Adapter/PHPArrayAdapterTests.php @@ -0,0 +1,58 @@ +configFile = __DIR__ . '/../cache.yml'; + + $configLoader = new Loader(); + $config = $configLoader->load($this->configFile); + + $configLoader->setAdapterName($this->adapterType); + + $processedConfiguration = $configLoader->process($this->adapterName, $config); + $this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; + } + + /** + * Tests creation of the filesystem cache item pool + * + * @author Damian Gręda + */ + public function testMake() + { + $filesystemAdapterFactory = new PHPArray(); + $filesystemCacheItemPool = $filesystemAdapterFactory->make($this->config); + + $this->assertInstanceOf('Psr\\Cache\\CacheItemPoolInterface', $filesystemCacheItemPool); + $this->assertInstanceOf('\\Cache\\Adapter\\PHPArray\\ArrayCachePool', $filesystemCacheItemPool); + } +} diff --git a/tests/cache.yml b/tests/cache.yml index efa7670..a650f27 100644 --- a/tests/cache.yml +++ b/tests/cache.yml @@ -3,3 +3,5 @@ Cache: local: type: Filesystem path: '/tmp' + memory: + type: PHPArray From 8306da5fef7561b31bbb98c25e325a79c0038f0d Mon Sep 17 00:00:00 2001 From: Kamil Iskierka Date: Tue, 26 Feb 2019 13:09:06 +0100 Subject: [PATCH 4/4] [WMS-1703] Base class for adapters tests --- tests/Adapter/BaseAdapterTests.php | 58 ++++++++++++++++++++++++ tests/Adapter/FilesystemAdapterTests.php | 30 +----------- tests/Adapter/PHPArrayAdapterTests.php | 32 +------------ 3 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 tests/Adapter/BaseAdapterTests.php diff --git a/tests/Adapter/BaseAdapterTests.php b/tests/Adapter/BaseAdapterTests.php new file mode 100644 index 0000000..149728e --- /dev/null +++ b/tests/Adapter/BaseAdapterTests.php @@ -0,0 +1,58 @@ +adapterName)) { + throw new Exception( + sprintf('Provide $adapterName in %s', (new ReflectionClass($this))->getFileName()) + ); + } elseif (!isset($this->adapterType)) { + throw new Exception( + sprintf('Provide $adapterType in %s', (new ReflectionClass($this))->getFileName()) + ); + } + + $this->configFile = __DIR__ . '/../cache.yml'; + + $configLoader = new Loader(); + $config = $configLoader->load($this->configFile); + + $configLoader->setAdapterName($this->adapterType); + + $processedConfiguration = $configLoader->process($this->adapterName, $config); + $this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; + } + + /** + * Tests creation of the filesystem cache item pool + */ + abstract public function testMake(); +} diff --git a/tests/Adapter/FilesystemAdapterTests.php b/tests/Adapter/FilesystemAdapterTests.php index 23894c6..47e5378 100644 --- a/tests/Adapter/FilesystemAdapterTests.php +++ b/tests/Adapter/FilesystemAdapterTests.php @@ -1,10 +1,8 @@ configFile = __DIR__ . '/../cache.yml'; - - $configLoader = new Loader(); - $config = $configLoader->load($this->configFile); - - $configLoader->setAdapterName($this->adapterType); - - $processedConfiguration = $configLoader->process($this->adapterName, $config); - $this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; - } - /** * Tests creation of the filesystem cache item pool * diff --git a/tests/Adapter/PHPArrayAdapterTests.php b/tests/Adapter/PHPArrayAdapterTests.php index 7202bc4..29c5269 100644 --- a/tests/Adapter/PHPArrayAdapterTests.php +++ b/tests/Adapter/PHPArrayAdapterTests.php @@ -1,10 +1,8 @@ configFile = __DIR__ . '/../cache.yml'; - - $configLoader = new Loader(); - $config = $configLoader->load($this->configFile); - - $configLoader->setAdapterName($this->adapterType); - - $processedConfiguration = $configLoader->process($this->adapterName, $config); - $this->config = $processedConfiguration[Config::INDEX_ADAPTER][$this->adapterName]; - } - /** * Tests creation of the filesystem cache item pool - * - * @author Damian Gręda */ public function testMake() {