Add visitor-IP header setting, checkout-button toggles, and configurable timer maximum
Test and Release / test (push) Successful in 1m13s
Test and Release / release (push) Successful in 5s

- Core\ClientIp: trusted-header resolution for rate limiting behind Cloudflare/proxies
- Settings: show/hide Pay Later and Debit/Credit Card (Pay Later off by default)
- add_time rule: optional max_timer_seconds (uncapped by default), editable in rule form

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 11:40:06 -08:00
1 parent 4f92cfdade
commit e4d9042aba
14 files changed
+278 -16

No files matched your search

+17 -2
View File
@@ -52,7 +52,7 @@ final class AdminLogicTest extends TestCase {
$r = RuleConfig::sanitize( 'add_time', array( 'time_amount' => '1', 'time_unit' => 'minutes', 'unit_amount' => '1.00', 'cap_minutes' => '10', 'max_total_minutes' => '' ), 'USD' );
$this->assertSame( array(), $r['errors'] );
$this->assertSame(
array( 'seconds_per_unit' => 60, 'unit_minor' => 100, 'cap_seconds_per_donation' => 600, 'max_total_seconds' => null, 'basis' => 'base' ),
array( 'seconds_per_unit' => 60, 'unit_minor' => 100, 'cap_seconds_per_donation' => 600, 'max_total_seconds' => null, 'max_timer_seconds' => null, 'basis' => 'base' ),
$r['config']
);
}
@@ -92,8 +92,23 @@ final class AdminLogicTest extends TestCase {
$this->assertSame( array( 'Timer: +25 minutes', 'Pies: +2', 'Bonus "big" does not trigger' ), RuleConfig::preview( $rules, 2500, 'USD' ) );
}
public function test_max_timer_validation_and_summary(): void {
$base = array( 'time_amount' => '1', 'time_unit' => 'minutes', 'unit_amount' => '1.00' );
$this->assertNull( RuleConfig::sanitize( 'add_time', $base, 'USD' )['config']['max_timer_seconds'] );
$this->assertNull( RuleConfig::sanitize( 'add_time', $base + array( 'max_timer_minutes' => ' ' ), 'USD' )['config']['max_timer_seconds'] );
$this->assertSame( 86400, RuleConfig::sanitize( 'add_time', $base + array( 'max_timer_minutes' => '1440' ), 'USD' )['config']['max_timer_seconds'] );
foreach ( array( '0', '-5', 'abc', '1.5' ) as $bad ) {
$r = RuleConfig::sanitize( 'add_time', $base + array( 'max_timer_minutes' => $bad ), 'USD' );
$this->assertNotEmpty( $r['errors'], $bad );
$this->assertNull( $r['config'] );
}
$this->assertSame( 'Adds 1 minute for every $1.00, up to 1 day on the clock', RuleConfig::summary( 'add_time', array( 'seconds_per_unit' => 60, 'unit_minor' => 100, 'max_timer_seconds' => 86400 ), 'USD' ) );
$this->assertSame( 'Adds 1 minute for every $1.00', RuleConfig::summary( 'add_time', array( 'seconds_per_unit' => 60, 'unit_minor' => 100 ), 'USD' ) );
$this->assertSame( array( 'Timer: +25 minutes (the timer never goes above 1 hour)' ), RuleConfig::preview( array( array( 'type' => 'add_time', 'config' => array( 'seconds_per_unit' => 60, 'unit_minor' => 100, 'max_timer_seconds' => 3600 ) ) ), 2500, 'USD' ) );
}
public function test_form_roundtrip(): void {
$cfg = array( 'seconds_per_unit' => 120, 'unit_minor' => 250, 'cap_seconds_per_donation' => 600, 'max_total_seconds' => null, 'basis' => 'base' );
$cfg = array( 'seconds_per_unit' => 120, 'unit_minor' => 250, 'cap_seconds_per_donation' => 600, 'max_total_seconds' => null, 'max_timer_seconds' => 86400, 'basis' => 'base' );
$form = RuleConfig::toForm( 'add_time', $cfg, 'USD' );
$back = RuleConfig::sanitize( 'add_time', $form, 'USD' );
$this->assertSame( $cfg, $back['config'] );