Skip to content

Commit 2ce71ca

Browse files
chore: remove BaseEntity oveloaded props and methods. fix skipped test
1 parent 11a9d57 commit 2ce71ca

3 files changed

Lines changed: 8 additions & 30 deletions

File tree

app/libs/Auth/Models/TwoFactorAuditLog.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
* limitations under the License.
1414
**/
1515

16+
use App\Models\Utils\BaseEntity;
1617
use Auth\User;
1718
use Doctrine\ORM\Mapping as ORM;
1819

1920
#[ORM\Table(name: 'two_factor_audit_log')]
2021
#[ORM\Entity(repositoryClass: \App\Repositories\DoctrineTwoFactorAuditLogRepository::class)]
21-
class TwoFactorAuditLog
22+
class TwoFactorAuditLog extends BaseEntity
2223
{
2324
public const EventChallengeIssued = 'challenge_issued';
2425
public const EventChallengeSucceeded = 'challenge_succeeded';
@@ -55,11 +56,6 @@ class TwoFactorAuditLog
5556
self::MethodRecovery,
5657
];
5758

58-
#[ORM\Id]
59-
#[ORM\GeneratedValue]
60-
#[ORM\Column(name: 'id', type: 'integer', unique: true, nullable: false)]
61-
protected $id;
62-
6359
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
6460
#[ORM\ManyToOne(targetEntity: \Auth\User::class)]
6561
private $user;
@@ -79,20 +75,13 @@ class TwoFactorAuditLog
7975
#[ORM\Column(name: 'metadata', type: 'json', nullable: true)]
8076
private $metadata;
8177

82-
#[ORM\Column(name: 'created_at', type: 'datetime')]
83-
private $created_at;
8478

8579
public function __construct()
8680
{
87-
$this->created_at = new \DateTime('now', new \DateTimeZone('UTC'));
81+
parent::__construct();
8882
$this->metadata = null;
8983
}
9084

91-
public function getId(): int
92-
{
93-
return (int) $this->id;
94-
}
95-
9685
public function getUser(): User
9786
{
9887
return $this->user;
@@ -158,9 +147,4 @@ public function setMetadata(?array $value): void
158147
{
159148
$this->metadata = $value;
160149
}
161-
162-
public function getCreatedAt(): \DateTime
163-
{
164-
return $this->created_at;
165-
}
166150
}

app/libs/Auth/Models/UserRecoveryCode.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,12 @@ class UserRecoveryCode extends BaseEntity
3535

3636
public function __construct()
3737
{
38-
$this->created_at = new \DateTime('now', new \DateTimeZone('UTC'));
38+
parent::__construct();
3939
$this->used_at = null;
4040
}
4141

42-
public function getId(): int
43-
{
44-
return (int) $this->id;
45-
}
4642

47-
public function getUser(): User
43+
public function getUser(): ?User
4844
{
4945
return $this->user;
5046
}
@@ -73,10 +69,6 @@ public function getUsedAt(): ?\DateTime
7369
return $this->used_at;
7470
}
7571

76-
public function getCreatedAt(): \DateTime
77-
{
78-
return $this->created_at;
79-
}
8072

8173
public function isUsed(): bool
8274
{

tests/TwoFactorRepositoriesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ public function testMarkUsedTwiceThrows(): void
375375

376376
public function testSetCodeHashRejectsPlaintext(): void
377377
{
378-
$this->markTestSkipped('setCodeHash() was removed from UserRecoveryCode; plaintext validation no longer has an entry point.');
378+
$code = new UserRecoveryCode();
379+
$this->expectException(\InvalidArgumentException::class);
380+
$code->setCodeHash('plaintext-not-a-hash');
379381
}
380382

381383
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)