Compare commits

..
Author SHA1 Message Date
shadowdaoandClaude Sonnet 5.5 875ca42054 CSV export: only completed donations (not abandoned checkouts)
Test and Release / test (push) Successful in 1m18s
Test and Release / release (push) Successful in 4s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 12:14:04 -08:00
2 changed files with 17 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -137,7 +137,7 @@ final class Store {
global $wpdb;
return (array) $wpdb->get_results(
$wpdb->prepare(
'SELECT * FROM ' . self::t( 'donations' ) . ' WHERE id > %d AND paypal_order_id NOT LIKE %s AND goal_id > 0 ORDER BY id ASC LIMIT %d',
'SELECT * FROM ' . self::t( 'donations' ) . ' WHERE id > %d AND status = \'completed\' AND paypal_order_id NOT LIKE %s AND goal_id > 0 ORDER BY id ASC LIMIT %d',
$afterId,
$wpdb->esc_like( Format::TEST_PREFIX ) . '%',
$limit
+16
View File
@@ -52,4 +52,20 @@ final class AdminStoreRulesTest extends TestCase {
$this->assertIsArray( $r['config'] );
$this->assertNull( Store::rule( 99, 1 ) );
}
public function test_export_only_selects_completed_non_test_donations(): void {
$captured = array();
$GLOBALS['wpdb'] = new class( $captured ) {
public string $prefix = 'wp_';
public function __construct( public array &$sql ) {}
public function esc_like( string $s ): string { return $s; }
public function prepare( string $q, ...$args ): string { return $q; }
public function get_results( string $q, $output = null ): array { $this->sql[] = $q; return array(); }
};
Store::exportBatch( 0, 100 );
$this->assertNotEmpty( $captured );
$this->assertStringContainsString( "status = 'completed'", $captured[0], 'abandoned/unpaid checkouts must not be exported' );
$this->assertStringContainsString( 'goal_id > 0', $captured[0], 'test donations must not be exported' );
}
}