Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Update PHPUnit (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Firehed committed Oct 26, 2021
1 parent 31535c6 commit 58a97aa
Show file tree
Hide file tree
Showing 19 changed files with 22 additions and 287 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"require-dev": {
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^8.5 || ^9.0",
"squizlabs/php_codesniffer": "^3.2",
"phpstan/phpstan-phpunit": "^0.12"
},
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parameters:
path: tests/ResponseTraitTest.php

-
message: "#^Method class@anonymous/tests/ResponseTraitTest\\.php\\:18\\:\\:parseResponse\\(\\) has parameter \\$response with no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/tests/ResponseTraitTest\\.php\\:16\\:\\:parseResponse\\(\\) has parameter \\$response with no value type specified in iterable type array\\.$#"
count: 1
path: tests/ResponseTraitTest.php

14 changes: 1 addition & 13 deletions tests/AppIdTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\AppIdTrait
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\AppIdTrait
*/
class AppIdTraitTest extends \PHPUnit\Framework\TestCase
{

/**
* @covers ::getAppId
* @covers ::setAppId
*/
public function testAccessors(): void
{
$obj = new class {
Expand All @@ -34,9 +28,6 @@ public function testAccessors(): void
);
}

/**
* @covers ::getApplicationParameter
*/
public function testGetApplicationParameter(): void
{
$obj = new class {
Expand All @@ -51,9 +42,6 @@ public function testGetApplicationParameter(): void
);
}

/**
* @covers ::getRpIdHash
*/
public function testGetRpIdHash(): void
{
$obj = new class {
Expand Down
16 changes: 1 addition & 15 deletions tests/AttestationCertificateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\AttestationCertificate
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\AttestationCertificate
*/
class AttestationCertificateTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::__construct
*/
public function testConstruct(): void
{
// Note: a future, stricter implementation which actually parses and
Expand All @@ -23,9 +18,6 @@ public function testConstruct(): void
$this->assertInstanceOf(AttestationCertificateInterface::class, $cert);
}

/**
* @covers ::getBinary
*/
public function testGetBinary(): void
{
$raw = random_bytes(128);
Expand All @@ -37,9 +29,6 @@ public function testGetBinary(): void
);
}

/**
* @covers ::getPemFormatted
*/
public function testGetPemFormatted(): void
{
$raw = random_bytes(128);
Expand All @@ -54,9 +43,6 @@ public function testGetPemFormatted(): void
);
}

/**
* @covers ::__debugInfo
*/
public function testDebugInfoEncodesBinary(): void
{
$cert = new AttestationCertificate(random_bytes(128));
Expand Down
8 changes: 1 addition & 7 deletions tests/ChallengeTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,11 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\ChallengeTrait
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\ChallengeTrait
*/
class ChallengeTraitTest extends \PHPUnit\Framework\TestCase
{

/**
* @covers ::getChallenge
* @covers ::setChallenge
*/
public function testAccessors(): void
{
$obj = new class {
Expand Down
17 changes: 1 addition & 16 deletions tests/ClientDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,10 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\ClientData
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\ClientData
*/
class ClientDataTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::fromJson
*/
public function testFromValidJson(): void
{
$goodData = [
Expand All @@ -27,9 +22,6 @@ public function testFromValidJson(): void
$this->assertInstanceOf(ClientData::class, $clientData);
}

/**
* @covers ::getChallengeParameter
*/
public function testGetChallengeParameter(): void
{
$expected_param = base64_decode('exDPjyyKbizXMAAUNLpv0QYJNyXClbUqewUWojPtp0g=');
Expand All @@ -53,9 +45,6 @@ public function testGetChallengeParameter(): void
);
}

/**
* @covers ::getApplicationParameter
*/
public function testGetApplicationParameter(): void
{
$goodData = [
Expand All @@ -73,9 +62,6 @@ public function testGetApplicationParameter(): void
);
}

/**
* @covers ::fromJson
*/
public function testBadJson(): void
{
$json = 'this is not json';
Expand All @@ -85,7 +71,6 @@ public function testBadJson(): void
}

/**
* @covers ::fromJson
* @dataProvider missingData
*/
public function testDataValidation(string $json): void
Expand Down
5 changes: 1 addition & 4 deletions tests/ClientErrorExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\ClientErrorException
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\ClientErrorException
*/
class ClientErrorExceptionTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::__construct
* @dataProvider clientErrors
*/
public function testClientError(int $code): void
Expand Down
25 changes: 1 addition & 24 deletions tests/ECPublicKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\ECPublicKey
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\ECPublicKey
*/
class ECPublicKeyTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::__construct
*/
public function testConstruct(): void
{
$key = "\x04".\random_bytes(64);
$obj = new ECPublicKey($key);
$this->assertInstanceOf(PublicKeyInterface::class, $obj);
}

/**
* @covers ::__construct
*/
public function testConstructThrowsWithBadFirstByte(): void
{
$key = "\x01".\random_bytes(64);
Expand All @@ -32,9 +24,6 @@ public function testConstructThrowsWithBadFirstByte(): void
}


/**
* @covers ::__construct
*/
public function testConstructThrowsWhenTooShort(): void
{
$key = "\x04".random_bytes(63);
Expand All @@ -43,9 +32,6 @@ public function testConstructThrowsWhenTooShort(): void
new ECPublicKey($key);
}

/**
* @covers ::__construct
*/
public function testConstructThrowsWhenTooLong(): void
{
$key = "\x04".random_bytes(65);
Expand All @@ -54,9 +40,6 @@ public function testConstructThrowsWhenTooLong(): void
new ECPublicKey($key);
}

/**
* @covers ::getBinary
*/
public function testGetBinary(): void
{
$key = "\x04".\random_bytes(64);
Expand All @@ -68,9 +51,6 @@ public function testGetBinary(): void
);
}

/**
* @covers ::getPemFormatted
*/
public function testGetPublicKeyPem(): void
{
$key = hex2bin(
Expand All @@ -88,9 +68,6 @@ public function testGetPublicKeyPem(): void
$this->assertSame($pem, $obj->getPemFormatted());
}

/**
* @covers ::__debugInfo
*/
public function testDebugInfoEncodesBinary(): void
{
$x = random_bytes(32);
Expand Down
5 changes: 1 addition & 4 deletions tests/InvalidDataExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\InvalidDataException
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\InvalidDataException
*/
class InvalidDataExceptionTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::__construct
* @dataProvider invalidDataExceptionCodes
*/
public function testInvalidDataException(int $code): void
Expand Down
11 changes: 1 addition & 10 deletions tests/KeyHandleTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\KeyHandleTrait
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\KeyHandleTrait
*/
class KeyHandleTraitTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers ::getKeyHandleBinary
* @covers ::setKeyHandle
*/
public function testAccessors(): void
{
$obj = new class {
Expand All @@ -32,9 +26,6 @@ public function testAccessors(): void
);
}

/**
* @covers ::getKeyHandleWeb
*/
public function testGetKeyHandleWeb(): void
{
$obj = new class {
Expand Down
8 changes: 1 addition & 7 deletions tests/RegisterRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
namespace Firehed\U2F;

/**
* @coversDefaultClass Firehed\U2F\RegisterRequest
* @covers ::<protected>
* @covers ::<private>
* @covers Firehed\U2F\RegisterRequest
*/
class RegisterRequestTest extends \PHPUnit\Framework\TestCase
{

/**
* @covers ::jsonSerialize
*/
public function testJsonSerialize(): void
{
$appId = 'https://u2f.example.com';
Expand Down
Loading

0 comments on commit 58a97aa

Please sign in to comment.