From 656bd4ad5ac5f46dafab455f703fdcd59f14d8c6 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Thu, 27 Jun 2024 09:10:48 -0400 Subject: [PATCH 1/3] Removing build folder from Git index Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- .gitignore | 1 + build/.gitignore | 4 ---- build/logs/.gitignore | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 build/.gitignore delete mode 100644 build/logs/.gitignore diff --git a/.gitignore b/.gitignore index 0315e54..bef7b9a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ vendor/* #ignoring NetBeans project files /nbproject .phpunit.result.cache +/build diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index 6d8e8bf..0000000 --- a/build/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!logs -!.gitignore -!coverage-checker.php \ No newline at end of file diff --git a/build/logs/.gitignore b/build/logs/.gitignore deleted file mode 100644 index c96a04f..0000000 --- a/build/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file From b9fdf7b5cfb744c80fac1aa20a63ff99e64f3f8b Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Thu, 27 Jun 2024 09:11:23 -0400 Subject: [PATCH 2/3] Added test-coverage-html to composer scripts Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1d9dec3..5b9830b 100644 --- a/composer.json +++ b/composer.json @@ -78,6 +78,7 @@ "cs-check": "phpcs", "cs-fix": "phpcbf", "test": "phpunit --colors=always", - "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" + "test-coverage": "phpunit --colors=always --coverage-clover clover.xml", + "test-coverage-html": "phpunit --coverage-html ./build/html" } } From f129e838265d0f9ee3197d5133676e7695dad758 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Thu, 27 Jun 2024 09:11:42 -0400 Subject: [PATCH 3/3] to fix #74 Signed-off-by: Eric Richer eric.richer@vistoconsulting.com --- src/Authentication/Adapter/AdapterChain.php | 3 +++ .../Adapter/AdapterChainServiceFactory.php | 4 ++++ src/Authentication/Adapter/Db.php | 11 +++++++++++ tests/Authentication/Adapter/DbTest.php | 10 ++++++++++ 4 files changed, 28 insertions(+) diff --git a/src/Authentication/Adapter/AdapterChain.php b/src/Authentication/Adapter/AdapterChain.php index a4c250e..9feaad6 100644 --- a/src/Authentication/Adapter/AdapterChain.php +++ b/src/Authentication/Adapter/AdapterChain.php @@ -105,6 +105,9 @@ public function resetAdapters() } } } + $event = $this->getEvent(); + $event->setName('reset'); + $this->getEventManager()->triggerEvent($event); return $this; } diff --git a/src/Authentication/Adapter/AdapterChainServiceFactory.php b/src/Authentication/Adapter/AdapterChainServiceFactory.php index a473e14..cdeae6a 100644 --- a/src/Authentication/Adapter/AdapterChainServiceFactory.php +++ b/src/Authentication/Adapter/AdapterChainServiceFactory.php @@ -27,6 +27,10 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, arr if (is_callable(array($adapter, 'logout'))) { $chain->getEventManager()->attach('logout', array($adapter, 'logout'), $priority); } + + if (is_callable(array($adapter, 'reset'))) { + $chain->getEventManager()->attach('reset', array($adapter, 'reset'), $priority); + } } return $chain; diff --git a/src/Authentication/Adapter/Db.php b/src/Authentication/Adapter/Db.php index a566ff2..a872bde 100644 --- a/src/Authentication/Adapter/Db.php +++ b/src/Authentication/Adapter/Db.php @@ -43,6 +43,17 @@ public function logout(AdapterChainEvent $e) $this->getStorage()->clear(); } + /** + * Called when authentication adapter is reset + * @param AdapterChainEvent $e + * + */ + public function reset(AdapterChainEvent $e): void + { + $this->getStorage()->clear(); + } + + /** * @param AdapterChainEvent $e * @return bool diff --git a/tests/Authentication/Adapter/DbTest.php b/tests/Authentication/Adapter/DbTest.php index dd40307..2b169f0 100644 --- a/tests/Authentication/Adapter/DbTest.php +++ b/tests/Authentication/Adapter/DbTest.php @@ -86,6 +86,16 @@ public function testLogout() $this->db->logout($this->authEvent); } + /** + * @covers \LmcUser\Authentication\Adapter\Db::reset + */ + public function testReset() + { + $this->storage->expects($this->once()) + ->method('clear'); + $this->db->reset($this->authEvent); + } + /** * @covers \LmcUser\Authentication\Adapter\Db::Authenticate */