Skip to content

Commit

Permalink
Merge pull request #89 from visto9259/fix_74
Browse files Browse the repository at this point in the history
Fix 74 and other cleanups
  • Loading branch information
visto9259 authored Jun 27, 2024
2 parents 4fd88d6 + f129e83 commit 61b42fe
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ vendor/*
#ignoring NetBeans project files
/nbproject
.phpunit.result.cache
/build
4 changes: 0 additions & 4 deletions build/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions build/logs/.gitignore

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 3 additions & 0 deletions src/Authentication/Adapter/AdapterChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public function resetAdapters()
}
}
}
$event = $this->getEvent();
$event->setName('reset');
$this->getEventManager()->triggerEvent($event);

return $this;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Authentication/Adapter/AdapterChainServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/Authentication/Adapter/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/Authentication/Adapter/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 61b42fe

Please sign in to comment.