libresign/tests/php/Unit/Enum/SignatureFlowTest.php
Vitor Mattos 4beb12d49c test: update SignatureFlow tests for NONE mode
Add NONE mode to valid flow provider and remove zero from
invalid numeric values since 0 is now a valid value (NONE).

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-17 05:53:38 +00:00

46 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Tests\Unit\Enum;
use OCA\Libresign\Enum\SignatureFlow;
use OCA\Libresign\Tests\Unit\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
final class SignatureFlowTest extends TestCase {
public static function validFlowProvider(): array {
return [
'none' => [SignatureFlow::NONE, SignatureFlow::NUMERIC_NONE, 'none'],
'parallel' => [SignatureFlow::PARALLEL, SignatureFlow::NUMERIC_PARALLEL, 'parallel'],
'ordered_numeric' => [SignatureFlow::ORDERED_NUMERIC, SignatureFlow::NUMERIC_ORDERED_NUMERIC, 'ordered_numeric'],
];
}
#[DataProvider('validFlowProvider')]
public function testBidirectionalConversion(SignatureFlow $flow, int $expectedNumeric, string $expectedString): void {
$this->assertEquals($expectedNumeric, $flow->toNumeric());
$this->assertSame($flow, SignatureFlow::fromNumeric($expectedNumeric));
$this->assertEquals($expectedString, $flow->value);
}
public static function invalidNumericProvider(): array {
return [
'negative' => [-1],
'three' => [3],
'large' => [999],
'max_int' => [PHP_INT_MAX],
];
}
#[DataProvider('invalidNumericProvider')]
public function testFromNumericRejectsInvalidValues(int $invalidValue): void {
$this->expectException(\ValueError::class);
$this->expectExceptionMessage("Invalid numeric value for SignatureFlow: $invalidValue");
SignatureFlow::fromNumeric($invalidValue);
}
}