Clear log repository on user deletion

This commit is contained in:
Thibaud Fabre
2016-09-29 09:57:48 +02:00
parent b98d8a38b2
commit bd7e0987bc
2 changed files with 7 additions and 3 deletions

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Model\Manager;
use Alchemy\Phrasea\Model\Entities\ApiLog;
use Doctrine\Common\Persistence\ObjectManager;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Entities\UserSetting;
@@ -44,7 +45,7 @@ class UserManager
* Deletes an user.
*
* @param User $user
* @param type $flush
* @param bool $flush
*/
public function delete(User $user, $flush = true)
{
@@ -52,8 +53,10 @@ class UserManager
$this->cleanRights($user);
$this->objectManager->persist($user);
if ($flush) {
$this->objectManager->flush();
$this->objectManager->clear(ApiLog::class);
}
}
@@ -61,11 +64,12 @@ class UserManager
* Updates an user.
*
* @param User $user
* @param type $flush
* @param bool $flush
*/
public function update(User $user, $flush = true)
{
$this->objectManager->persist($user);
if ($flush) {
$this->objectManager->flush();
}

View File

@@ -79,7 +79,7 @@ class UserDeletionTest extends \PhraseanetAuthenticatedWebTestCase
$apiLog = $apiLogManipulator->create($account, new Request(), new Response());
$apiLogId = $apiLog->getId();
$this->userManipulator->delete($this->user);
$this->userManipulator->delete($this->user, true);
$this->assertTrue($this->user->isDeleted(), 'User was not properly deleted');
$apiLogRepository->clear();