8
0
Fork 0

add further tests

Dieser Commit ist enthalten in:
Daniel Seifert 2022-12-13 22:16:45 +01:00
Ursprung f16fbee5d8
Commit 4183ebcf99
Signiert von: DanielS
GPG-Schlüssel-ID: 6A513E13AEE66170
1 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -21,6 +21,7 @@ use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
use D3\Webauthn\Application\Model\Exceptions\WebauthnException; use D3\Webauthn\Application\Model\Exceptions\WebauthnException;
use D3\Webauthn\Application\Model\Webauthn; use D3\Webauthn\Application\Model\Webauthn;
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn; use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
use Exception;
use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\Utils; use OxidEsales\Eshop\Core\Utils;
@ -319,11 +320,13 @@ class d3user_webauthnTest extends TestCase
/** /**
* @test * @test
* @param string $excClass
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @dataProvider canSaveAuthnFailedDataProvider
* @covers \D3\Webauthn\Application\Controller\Admin\d3user_webauthn::saveAuthn * @covers \D3\Webauthn\Application\Controller\Admin\d3user_webauthn::saveAuthn
*/ */
public function canSaveAuthnFailed() public function canSaveAuthnFailed(string $excClass)
{ {
$_POST['credential'] = 'msg'; $_POST['credential'] = 'msg';
$_POST['keyname'] = 'key_name'; $_POST['keyname'] = 'key_name';
@ -333,7 +336,7 @@ class d3user_webauthnTest extends TestCase
->onlyMethods(['saveAuthn']) ->onlyMethods(['saveAuthn'])
->getMock(); ->getMock();
$webauthnMock->expects($this->once())->method('saveAuthn') $webauthnMock->expects($this->once())->method('saveAuthn')
->willThrowException(oxNew(WebauthnException::class)); ->willThrowException(oxNew($excClass));
/** @var UtilsView|MockObject $utilsViewMock */ /** @var UtilsView|MockObject $utilsViewMock */
$utilsViewMock = $this->getMockBuilder(UtilsView::class) $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 * @test
* @return void * @return void