Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^11.0",
"squizlabs/php_codesniffer": "^3.6"
},
"suggest": {
Expand Down
18 changes: 8 additions & 10 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
cacheDirectory=".phpunit.cache"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="false"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
displayDetailsOnAllIssues="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
16 changes: 8 additions & 8 deletions tests/HOTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace Firehed\Security;

/**
* @covers Firehed\Security\OTP
* @covers Firehed\Security\HOTP
*/
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\DataProvider;

#[CoversClass(OTP::class)]
#[CoversFunction('Firehed\Security\HOTP')]
class HOTPTest extends \PHPUnit\Framework\TestCase
{
/**
Expand All @@ -17,7 +19,7 @@ class HOTPTest extends \PHPUnit\Framework\TestCase
*
* @return array{Secret, int, string}[]
*/
public function vectors(): array
public static function vectors(): array
{
$secret = new Secret('12345678901234567890');
return [
Expand All @@ -34,9 +36,7 @@ public function vectors(): array
];
}

/**
* @dataProvider vectors
*/
#[DataProvider('vectors')]
public function testHOTP(Secret $secret, int $counter, string $out): void
{
self::assertSame(
Expand Down
6 changes: 3 additions & 3 deletions tests/SecretKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Firehed\Security;

/**
* @covers Firehed\Security\SecretKey
*/
use PHPUnit\Framework\Attributes\CoversClass;

#[CoversClass(SecretKey::class)]
class SecretKeyTest extends \PHPUnit\Framework\TestCase
{
public function testGetKey(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/SecretTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Firehed\Security;

/**
* @covers Firehed\Security\Secret
*/
use PHPUnit\Framework\Attributes\CoversClass;

#[CoversClass(Secret::class)]
class SecretTest extends \PHPUnit\Framework\TestCase
{
public function testConstruct(): void
Expand Down
14 changes: 8 additions & 6 deletions tests/TOTPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@

namespace Firehed\Security;

/**
* @covers Firehed\Security\OTP
* @covers Firehed\Security\TOTP
*/
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\Attributes\DataProvider;

#[CoversClass(OTP::class)]
#[CoversFunction('Firehed\Security\TOTP')]
class TOTPTest extends \PHPUnit\Framework\TestCase
{
/**
* Test vectors provided by RFC 6238, Appendix B
*
* @return array{int, string, 'sha1'|'sha256'|'sha512', Secret}[]
*/
public function TOTPvectors(): array
public static function TOTPvectors(): array
{
// It's unclear that the token is of varying length based on the
// algoritm being used, but that's definitely the case
Expand Down Expand Up @@ -46,9 +48,9 @@ public function TOTPvectors(): array
}

/**
* @dataProvider TOTPvectors
* @param 'sha1'|'sha256'|'sha512' $algo
*/
#[DataProvider('TOTPvectors')]
public function testTOTPVectors(
int $ts,
string $expectedOut,
Expand Down
Loading