assertArrayHasKey( 'donation_notice', $d );
$this->assertStringContainsString( 'non-refundable', strtolower( (string) $d['donation_notice'] ) );
}
public function test_admin_input_is_plain_text_and_length_capped(): void {
$this->assertSame( 'No refunds, sorry.', Input::text( ' No refunds, sorry. ', 200 ) );
$this->assertStringNotContainsString( '<', Input::text( 'Hi', 200 ), 'no markup survives (and it is rendered as text anyway)' );
$this->assertStringNotContainsString( '<', Input::text( 'Bold text', 200 ) );
$this->assertSame( 200, strlen( Input::text( str_repeat( 'a', 500 ), 200 ) ) );
$this->assertSame( '', Input::text( "\x00\x1F", 200 ) );
}
public function test_form_script_renders_the_notice_with_textcontent_only(): void {
$js = (string) file_get_contents( dirname( __DIR__, 2 ) . '/assets/donate/donate.js' );
$this->assertMatchesRegularExpression( '/if \(C\.notice\).*sg-notice.*text: String\(C\.notice\)/s', $js, 'notice must be rendered as text, never HTML' );
$this->assertStringNotContainsString( 'innerHTML', $js );
}
public function test_form_config_passes_the_notice_through(): void {
$php = (string) file_get_contents( dirname( __DIR__, 2 ) . '/includes/Rest/DonateController.php' );
$this->assertStringContainsString( "'notice' => (string) ( \$s['donation_notice'] ?? '' )", $php );
}
}