Files

27 lines
1.2 KiB
PHP
Raw Permalink Normal View History

<?php
declare( strict_types=1 );
namespace StreamGoals\Tests\Unit;
use PHPUnit\Framework\TestCase;
use StreamGoals\PayPal\RequestId;
final class RequestIdTest extends TestCase {
public function test_stable_per_donation_and_within_paypal_limit(): void {
$a = RequestId::make( 'order', 42, '2026-01-01 10:00:00', 'salt' );
$this->assertSame( $a, RequestId::make( 'order', 42, '2026-01-01 10:00:00', 'salt' ) );
$this->assertLessThanOrEqual( 108, strlen( $a ) );
$this->assertMatchesRegularExpression( '/^sg-order-[0-9a-f]{64}$/', $a );
}
public function test_reused_auto_increment_id_gets_a_different_key(): void {
$this->assertNotSame( RequestId::make( 'order', 42, '2026-01-01 10:00:00', 's' ), RequestId::make( 'order', 42, '2026-01-02 10:00:00', 's' ) );
}
public function test_not_derivable_without_the_salt_and_kinds_differ(): void {
$this->assertNotSame( RequestId::make( 'order', 42, 't', 'salt1' ), RequestId::make( 'order', 42, 't', 'salt2' ) );
$this->assertNotSame( RequestId::make( 'order', 42, 't', 's' ), RequestId::make( 'capture', 42, 't', 's' ) );
$this->assertStringNotContainsString( 'sg-order-42', RequestId::make( 'order', 42, 't', 's' ) );
}
}