Skip to content

Commit

Permalink
DEP Use PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Sep 9, 2024
1 parent 7a9e737 commit db7a4f7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"guzzlehttp/psr7": "^2"
},
"require-dev": {
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^11.3",
"squizlabs/php_codesniffer": "^3",
"silverstripe/documentation-lint": "^1",
"silverstripe/standards": "^1",
Expand Down
11 changes: 6 additions & 5 deletions tests/RegisterHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Webauthn\PublicKeyCredentialLoader;
use Webauthn\PublicKeyCredentialSource;
use Webauthn\TrustPath\EmptyTrustPath;
use PHPUnit\Framework\Attributes\DataProvider;

class RegisterHandlerTest extends SapphireTest
{
Expand Down Expand Up @@ -88,8 +89,8 @@ protected function tearDown(): void
/**
* @param string $baseUrl
* @param string $expected
* @dataProvider hostProvider
*/
#[DataProvider('hostProvider')]
public function testRelyingPartyEntityDomainIncludesSilverStripeDomain(string $baseUrl, string $expected)
{
$_SERVER['HTTP_HOST'] = $baseUrl;
Expand All @@ -112,7 +113,7 @@ public function testRelyingPartyEntityDomainIncludesSilverStripeDomain(string $b
/**
* @return array
*/
public function hostProvider(): array
public static function hostProvider(): array
{
return [
'domain only' => ['http://example.com', 'example.com'],
Expand Down Expand Up @@ -167,8 +168,8 @@ public function testRegisterReturnsErrorWhenRequiredInformationIsMissing()
* @param int $expectedCredentialCount
* @param callable $responseValidatorMockCallback
* @throws Exception
* @dataProvider registerProvider
*/
#[DataProvider('registerProvider')]
public function testRegister(
$mockResponse,
$expectedResult,
Expand All @@ -178,7 +179,7 @@ public function testRegister(
) {
/** @var RegisterHandler&MockObject $handlerMock */
$handlerMock = $this->getMockBuilder(RegisterHandler::class)
->setMethods(['getPublicKeyCredentialLoader', 'getAuthenticatorAttestationResponseValidator'])
->onlyMethods(['getPublicKeyCredentialLoader', 'getAuthenticatorAttestationResponseValidator'])
->getMock();

$publicKeyCredentialSourceMock = $this->createMock(PublicKeyCredentialSource::class);
Expand Down Expand Up @@ -233,7 +234,7 @@ public function testRegister(
*
* @return array[]
*/
public function registerProvider()
public static function registerProvider()
{
// phpcs:disable
$testSource = PublicKeyCredentialSource::createFromArray([
Expand Down
11 changes: 6 additions & 5 deletions tests/VerifyHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Webauthn\PublicKeyCredentialSource;
use Webauthn\TrustPath\EmptyTrustPath;
use SilverStripe\WebAuthn\ResponseDataException;
use PHPUnit\Framework\Attributes\DataProvider;

class VerifyHandlerTest extends SapphireTest
{
Expand Down Expand Up @@ -123,16 +124,16 @@ public function testVerifyReturnsErrorWhenRequiredInformationIsMissing()
* @param AuthenticatorResponse $mockResponse
* @param Result $expectedResult
* @param callable $responseValidatorMockCallback
* @dataProvider verifyProvider
*/
#[DataProvider('verifyProvider')]
public function testVerify(
$mockResponse,
$expectedResult,
callable $responseValidatorMockCallback = null
) {
/** @var VerifyHandler&MockObject $handlerMock */
$handlerMock = $this->getMockBuilder(VerifyHandler::class)
->setMethods(['getPublicKeyCredentialLoader', 'getAuthenticatorAssertionResponseValidator'])
->onlyMethods(['getPublicKeyCredentialLoader', 'getAuthenticatorAssertionResponseValidator'])
->getMock();

$publicKeyCredentialSourceMock = $this->createMock(PublicKeyCredentialSource::class);
Expand Down Expand Up @@ -178,7 +179,7 @@ public function testVerify(
*
* @return array[]
*/
public function verifyProvider()
public static function verifyProvider()
{
return [
'wrong response return type' => [
Expand Down Expand Up @@ -212,8 +213,8 @@ function (MockObject $responseValidatorMock) {
}

/**
* @dataProvider provideMakeAuthenticatorDataBase64UrlSafe
*/
#[DataProvider('provideMakeAuthenticatorDataBase64UrlSafe')]
public function testMakeAuthenticatorDataBase64UrlSafe(array $data, string $expected, bool $exception)
{
$reflector = new \ReflectionClass(VerifyHandler::class);
Expand All @@ -232,7 +233,7 @@ public function testMakeAuthenticatorDataBase64UrlSafe(array $data, string $expe
}
}

public function provideMakeAuthenticatorDataBase64UrlSafe(): array
public static function provideMakeAuthenticatorDataBase64UrlSafe(): array
{
$makeData = function ($authenticatorData) {
$a = [];
Expand Down

0 comments on commit db7a4f7

Please sign in to comment.