Skip to content

Commit 7c5b620

Browse files
authored
Merge pull request #478 from dotkernel/issue-453
Issue 453
2 parents 4e54440 + 906530e commit 7c5b620

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

src/User/src/Entity/User.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ class User extends AbstractEntity implements UserInterface
3434
public const IS_DELETED_YES = true;
3535
public const IS_DELETED_NO = false;
3636

37-
public const IS_DELETED = [
38-
self::IS_DELETED_YES,
39-
self::IS_DELETED_NO,
40-
];
37+
public const IS_DELETED = ['1', '0'];
4138

4239
#[ORM\OneToOne(mappedBy: 'user', targetEntity: UserDetail::class, cascade: ['persist', 'remove'])]
4340
protected UserDetail $detail;

src/User/src/Form/ProfileDeleteForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function init(): void
4545
],
4646
'options' => [
4747
'label' => 'I want to delete account',
48-
'use_hidden_element' => true,
48+
'use_hidden_element' => false,
4949
'checked_value' => (string) User::IS_DELETED_YES,
5050
'unchecked_value' => (string) User::IS_DELETED_NO,
5151
],

src/User/src/Service/UserService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function updateUser(User $user, array $data = []): User
133133
}
134134

135135
if (isset($data['isDeleted'])) {
136-
$user->setIsDeleted($data['isDeleted']);
136+
$user->setIsDeleted((bool) $data['isDeleted']);
137137
}
138138

139139
if (isset($data['hash'])) {

test/Unit/User/InputFilter/ProfileDeleteInputFilterTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace FrontendTest\Unit\User\InputFilter;
66

77
use Frontend\App\Common\Message;
8+
use Frontend\User\Entity\User;
89
use Frontend\User\InputFilter\ProfileDeleteInputFilter;
910
use FrontendTest\Common\AbstractInputFilterTest;
1011
use Laminas\Session\Container;
@@ -51,10 +52,10 @@ public function testWillPassValidation(): void
5152
{
5253
$hash = (new Csrf(['session' => new Container()]))->getHash();
5354

54-
$this->inputFilter->setData(['isDeleted' => true, 'userDeleteCsrf' => $hash]);
55+
$this->inputFilter->setData(['isDeleted' => (string) User::IS_DELETED_YES, 'userDeleteCsrf' => $hash]);
5556
$this->assertTrue($this->inputFilter->isValid());
5657
$this->assertSame(
57-
true,
58+
(string) User::IS_DELETED_YES,
5859
$this->inputFilter->getValue('isDeleted')
5960
);
6061
}

0 commit comments

Comments
 (0)