From 906530ef2aff261150f997c4d5d9b1bdd0e9fed9 Mon Sep 17 00:00:00 2001 From: bidi Date: Wed, 4 Sep 2024 15:16:48 +0300 Subject: [PATCH] updated account delete Signed-off-by: bidi --- src/User/src/Entity/User.php | 5 +---- src/User/src/InputFilter/ProfileDeleteInputFilter.php | 2 +- test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php | 5 +++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/User/src/Entity/User.php b/src/User/src/Entity/User.php index ea9a5600..5746af2f 100644 --- a/src/User/src/Entity/User.php +++ b/src/User/src/Entity/User.php @@ -34,10 +34,7 @@ class User extends AbstractEntity implements UserInterface public const IS_DELETED_YES = true; public const IS_DELETED_NO = false; - public const IS_DELETED = [ - self::IS_DELETED_YES, - self::IS_DELETED_NO, - ]; + public const IS_DELETED = ['1', '0']; #[ORM\OneToOne(mappedBy: 'user', targetEntity: UserDetail::class, cascade: ['persist', 'remove'])] protected UserDetail $detail; diff --git a/src/User/src/InputFilter/ProfileDeleteInputFilter.php b/src/User/src/InputFilter/ProfileDeleteInputFilter.php index 077d0e5e..b8239dc3 100644 --- a/src/User/src/InputFilter/ProfileDeleteInputFilter.php +++ b/src/User/src/InputFilter/ProfileDeleteInputFilter.php @@ -31,7 +31,7 @@ public function init(): void ->attachByName(InArray::class, [ 'haystack' => User::IS_DELETED, 'message' => Message::DELETE_ACCOUNT, - 'strict' => InArray::COMPARE_NOT_STRICT, + 'strict' => InArray::COMPARE_STRICT, ], true) ->attachByName(NotEmpty::class, [ 'message' => Message::DELETE_ACCOUNT, diff --git a/test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php b/test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php index 97d17db4..01a7abb3 100644 --- a/test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php +++ b/test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php @@ -5,6 +5,7 @@ namespace FrontendTest\Unit\User\InputFilter; use Frontend\App\Common\Message; +use Frontend\User\Entity\User; use Frontend\User\InputFilter\ProfileDeleteInputFilter; use FrontendTest\Common\AbstractInputFilterTest; use Laminas\Session\Container; @@ -51,10 +52,10 @@ public function testWillPassValidation(): void { $hash = (new Csrf(['session' => new Container()]))->getHash(); - $this->inputFilter->setData(['isDeleted' => true, 'userDeleteCsrf' => $hash]); + $this->inputFilter->setData(['isDeleted' => (string) User::IS_DELETED_YES, 'userDeleteCsrf' => $hash]); $this->assertTrue($this->inputFilter->isValid()); $this->assertSame( - true, + (string) User::IS_DELETED_YES, $this->inputFilter->getValue('isDeleted') ); }