From 30c7ca4627c648a3f98fe3edbf506a9a5c89cff3 Mon Sep 17 00:00:00 2001 From: Ian Lindsay Date: Wed, 13 Nov 2024 17:41:33 +0000 Subject: [PATCH] feat: check whether terms agreed VOL-5664 --- Common/src/Common/Rbac/User.php | 5 +++++ test/Common/src/Common/Rbac/UserTest.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Common/src/Common/Rbac/User.php b/Common/src/Common/Rbac/User.php index f7dcb7df7..44a1f25d5 100644 --- a/Common/src/Common/Rbac/User.php +++ b/Common/src/Common/Rbac/User.php @@ -208,4 +208,9 @@ public function hasRole($role): bool { return in_array($role, $this->getRoles(), true); } + + public function hasAgreedTerms(): bool + { + return $this->userData['termsAgreed']; + } } diff --git a/test/Common/src/Common/Rbac/UserTest.php b/test/Common/src/Common/Rbac/UserTest.php index 847170c0f..036d68953 100644 --- a/test/Common/src/Common/Rbac/UserTest.php +++ b/test/Common/src/Common/Rbac/UserTest.php @@ -1,5 +1,7 @@ assertEquals($roles, $this->sut->getRoles()); $this->assertFalse($this->sut->hasRole(RefData::ROLE_INTERNAL_ADMIN)); } + + public function testHasAgreedTermsTrue(): void + { + $userData = ['termsAgreed' => true]; + $this->sut->setUserData($userData); + $this->assertTrue($this->sut->hasAgreedTerms()); + } + + public function testHasAgreedTermsFalse(): void + { + $userData = ['termsAgreed' => false]; + $this->sut->setUserData($userData); + $this->assertFalse($this->sut->hasAgreedTerms()); + } }