Files
wp-donations/tests/Unit/PageCacheOptOutTest.php
T
shadowdaoandClaude Sonnet 5.5 96bae1cbf9
Test and Release / test (push) Successful in 3m47s
Test and Release / release (push) Successful in 13s
Keep overlays and live responses out of LiteSpeed Cache
LiteSpeed Cache held overlay poll responses for 7 days, so OBS kept getting
304s and neither the goal bar nor alerts updated after a donation. The overlay
data, overlay pages and fee preview now opt out, as the progress route did.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-27 21:07:57 -08:00

30 lines
1.2 KiB
PHP

<?php
declare( strict_types=1 );
namespace StreamGoals\Tests\Unit;
use PHPUnit\Framework\TestCase;
/** Live responses must opt out of page caching, or OBS overlays freeze behind LiteSpeed Cache. */
final class PageCacheOptOutTest extends TestCase {
public function test_every_live_response_opts_out_of_page_caching(): void {
$root = dirname( __DIR__, 2 ) . '/includes/';
$expected = array(
'Rest/OverlayController.php' => "PageCache::skip( 'overlay data' )",
'Overlay/Router.php' => "PageCache::skip( 'overlay page' )",
'Rest/DonateController.php' => "PageCache::skip( 'fee preview' )",
);
foreach ( $expected as $file => $call ) {
$this->assertStringContainsString( $call, (string) file_get_contents( $root . $file ), $file );
}
$helper = (string) file_get_contents( $root . 'Core/PageCache.php' );
$this->assertStringContainsString( 'litespeed_control_set_nocache', $helper );
}
public function test_overlay_opts_out_before_the_token_check_so_404s_are_not_cached(): void {
$src = (string) file_get_contents( dirname( __DIR__, 2 ) . '/includes/Rest/OverlayController.php' );
$this->assertLessThan( strpos( $src, 'self::verify_token( (string)' ), strpos( $src, 'PageCache::skip(' ) );
}
}