getUserConsentMock = $this->createMock(GetUserConsentInterface::class); $this->isOptInModel = new IsOptIn($this->getUserConsentMock); } public function testNotHaveConsent() { $this->getUserConsentMock ->method('execute') ->willThrowException(new NotFoundException(__('User didnt make any consents.'))); $this->assertFalse($this->isOptInModel->execute()); } public function testHaveConsent() { $this->getUserConsentMock ->method('execute') ->willReturn(['test_essential', 'test_marketing']); $this->assertTrue($this->isOptInModel->execute()); } public function testHaveAllConsent() { $this->getUserConsentMock ->method('execute') ->willReturn([CategoryInterface::ALL_CATEGORIES]); $this->assertTrue($this->isOptInModel->execute()); } }