From 4183ebcf99ea8b1a017e03d96c78fa258d32ba98 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 13 Dec 2022 22:16:45 +0100 Subject: [PATCH] add further tests --- .../Controller/Admin/d3user_webauthnTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tests/unit/Application/Controller/Admin/d3user_webauthnTest.php b/src/tests/unit/Application/Controller/Admin/d3user_webauthnTest.php index d0b950b..714e9fb 100644 --- a/src/tests/unit/Application/Controller/Admin/d3user_webauthnTest.php +++ b/src/tests/unit/Application/Controller/Admin/d3user_webauthnTest.php @@ -21,6 +21,7 @@ use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList; use D3\Webauthn\Application\Model\Exceptions\WebauthnException; use D3\Webauthn\Application\Model\Webauthn; use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn; +use Exception; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Utils; @@ -319,11 +320,13 @@ class d3user_webauthnTest extends TestCase /** * @test + * @param string $excClass * @return void * @throws ReflectionException + * @dataProvider canSaveAuthnFailedDataProvider * @covers \D3\Webauthn\Application\Controller\Admin\d3user_webauthn::saveAuthn */ - public function canSaveAuthnFailed() + public function canSaveAuthnFailed(string $excClass) { $_POST['credential'] = 'msg'; $_POST['keyname'] = 'key_name'; @@ -333,7 +336,7 @@ class d3user_webauthnTest extends TestCase ->onlyMethods(['saveAuthn']) ->getMock(); $webauthnMock->expects($this->once())->method('saveAuthn') - ->willThrowException(oxNew(WebauthnException::class)); + ->willThrowException(oxNew($excClass)); /** @var UtilsView|MockObject $utilsViewMock */ $utilsViewMock = $this->getMockBuilder(UtilsView::class) @@ -380,6 +383,17 @@ class d3user_webauthnTest extends TestCase ); } + /** + * @return array[] + */ + public function canSaveAuthnFailedDataProvider(): array + { + return [ + 'webauthn exception' => [WebauthnException::class], + 'common exception' => [Exception::class], + ]; + } + /** * @test * @return void