End-at-target goals (auto-close when target reached) and fit-to-window rewards menu overlay
- Core\GoalTargetPolicy; atomic close in the capture path; friendly 'goal reached' message - In-flight checkouts still capture; new orders for a closed goal are refused - Rewards menu overlay: card hugs content, text scales to the window, resize-aware, scroll only as a last resort Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1c6d93ad5f
commit
5ea1e1d273
9 files changed
+216
-19
No files matched your search
@@ -38,8 +38,8 @@ body.sg-offline #sg-root{opacity:.6}
|
||||
@media (prefers-reduced-motion:reduce){.sg-fill{transition:none}.sg-alert,.sg-alert.sg-out,.sg-alert.sg-bonus,.sg-alert.sg-bonus.sg-out{animation:none}.sg-alert.sg-bonus{box-shadow:0 0 .8em var(--sg-accent2)}}
|
||||
.sg-w-actions #sg-root{align-items:flex-start}
|
||||
.sg-w-actions #sg-root:empty{display:none}
|
||||
.sg-menu{height:100%;display:flex;flex-direction:column;overflow:hidden}
|
||||
.sg-menu-view{flex:1;min-height:0;overflow:hidden}
|
||||
.sg-menu{height:auto;display:flex;flex-direction:column;overflow:hidden;font-size:calc(1em * var(--sg-menu-scale,1))}
|
||||
.sg-menu-view{flex:none;min-height:0;overflow:hidden}
|
||||
.sg-menu-list{list-style:none;margin:0;padding:0}
|
||||
.sg-menu-item{padding:.3em 0;font-weight:600;overflow-wrap:anywhere}
|
||||
.sg-menu-item b{color:var(--sg-accent2);font-weight:800}
|
||||
|
||||
+40
-12
@@ -146,14 +146,50 @@
|
||||
}
|
||||
|
||||
// ---- actions (reward menu) ----
|
||||
// Renders nothing visible when there are no actions. Long lists scroll gently via CSS (--sg-rows sets the duration).
|
||||
var actionsSig = null;
|
||||
// Renders nothing visible when there are no actions. The card hugs its content and the text is scaled to the
|
||||
// LARGEST size that still fits the browser-source window (shrinks for long lists, grows for short ones), and
|
||||
// re-fits when the window is resized. Only if even the smallest size does not fit does it fall back to a gentle scroll.
|
||||
var actionsSig = null, menuEls = null, fitTimer = 0;
|
||||
var MENU_MIN = 0.5, MENU_MAX = 1.8;
|
||||
function fitMenu() {
|
||||
if (!menuEls) return;
|
||||
var card = menuEls.card, view = menuEls.view, track = menuEls.track, ul = menuEls.ul;
|
||||
// reset any previous scroll fallback
|
||||
track.classList.remove('sg-scrolling');
|
||||
while (track.children.length > 1) track.removeChild(track.lastChild);
|
||||
view.style.height = '';
|
||||
var cs = getComputedStyle(root);
|
||||
var inner = root.clientHeight - parseFloat(cs.paddingTop) - parseFloat(cs.paddingBottom);
|
||||
if (inner <= 0) return;
|
||||
function fits(scale) {
|
||||
card.style.setProperty('--sg-menu-scale', String(scale));
|
||||
return card.offsetHeight <= inner;
|
||||
}
|
||||
var lo = MENU_MIN, hi = MENU_MAX, best = null;
|
||||
if (fits(hi)) { best = hi; }
|
||||
else if (!fits(lo)) { best = null; }
|
||||
else { for (var i = 0; i < 9; i++) { var mid = (lo + hi) / 2; if (fits(mid)) { lo = mid; } else { hi = mid; } } best = lo; }
|
||||
if (best !== null) { card.style.setProperty('--sg-menu-scale', String(best)); return; }
|
||||
// Even the smallest size overflows: use the smallest and scroll gently inside the window.
|
||||
card.style.setProperty('--sg-menu-scale', String(MENU_MIN));
|
||||
var chrome = card.offsetHeight - view.offsetHeight;
|
||||
view.style.height = Math.max(40, inner - chrome) + 'px';
|
||||
var dup = ul.cloneNode(true);
|
||||
dup.setAttribute('aria-hidden', 'true');
|
||||
track.appendChild(dup);
|
||||
track.style.setProperty('--sg-scroll-s', Math.max(8, menuEls.count * 3) + 's');
|
||||
track.classList.add('sg-scrolling');
|
||||
}
|
||||
function scheduleFit() { clearTimeout(fitTimer); fitTimer = setTimeout(fitMenu, 120); }
|
||||
window.addEventListener('resize', scheduleFit);
|
||||
if (typeof ResizeObserver === 'function') { try { new ResizeObserver(scheduleFit).observe(document.documentElement); } catch (e) { /* resize event is the fallback */ } }
|
||||
function renderActions(d) {
|
||||
var list = Array.isArray(d.actions) ? d.actions : [];
|
||||
var sig = JSON.stringify(list);
|
||||
if (sig === actionsSig) return;
|
||||
actionsSig = sig;
|
||||
root.textContent = '';
|
||||
menuEls = null;
|
||||
if (!d.active || !list.length) return;
|
||||
var card = el('div', 'sg-card sg-menu');
|
||||
var view = el('div', 'sg-menu-view');
|
||||
@@ -171,16 +207,8 @@
|
||||
view.appendChild(track);
|
||||
card.appendChild(view);
|
||||
root.appendChild(card);
|
||||
// Overflow check after layout: duplicate the list for a seamless loop and start the CSS scroll.
|
||||
requestAnimationFrame(function () {
|
||||
if (ul.scrollHeight > view.clientHeight + 2) {
|
||||
var dup = ul.cloneNode(true);
|
||||
dup.setAttribute('aria-hidden', 'true');
|
||||
track.appendChild(dup);
|
||||
track.style.setProperty('--sg-scroll-s', Math.max(8, list.length * 3) + 's');
|
||||
track.classList.add('sg-scrolling');
|
||||
}
|
||||
});
|
||||
menuEls = { card: card, view: view, track: track, ul: ul, count: list.length };
|
||||
requestAnimationFrame(fitMenu);
|
||||
}
|
||||
|
||||
// ---- polling ----
|
||||
|
||||
@@ -43,7 +43,7 @@ final class GoalsPage {
|
||||
$pct = $target > 0 ? min( 100, intdiv( $raised * 100, $target ) ) : 0;
|
||||
echo '<tr><td><strong>' . esc_html( (string) $g['title'] ) . '</strong><br><span class="description">ID ' . $gid . ' · <code>[streamgoals_donate goal="' . $gid . '"]</code></span></td>';
|
||||
echo '<td><span class="sg-badge sg-' . esc_attr( (string) $g['status'] ) . '">' . esc_html( self::STATUSES[ $g['status'] ] ?? (string) $g['status'] ) . '</span></td>';
|
||||
echo '<td>' . esc_html( Format::money( $raised, $cur ) . ' of ' . Format::money( $target, $cur ) ) . ' (' . (int) $pct . '%)<div class="sg-bar"><span style="width:' . (int) $pct . '%"></span></div></td>';
|
||||
echo '<td>' . esc_html( Format::money( $raised, $cur ) . ' of ' . Format::money( $target, $cur ) ) . ' (' . (int) $pct . '%)<div class="sg-bar"><span style="width:' . (int) $pct . '%"></span></div>' . ( ! empty( $g['close_at_target'] ) ? '<span class="description">Closes at target</span>' : '' ) . '</td>';
|
||||
echo '<td>' . esc_html( self::dateLabel( $g['starts_at'] ?? null, 'Starts' ) ) . '<br>' . esc_html( self::dateLabel( $g['ends_at'] ?? null, 'Ends' ) ) . '</td><td class="sg-actions">';
|
||||
echo '<a class="button" href="' . esc_url( Admin::url( Admin::HOME, array( 'view' => 'edit', 'goal' => $gid ) ) ) . '">Edit</a> ';
|
||||
echo '<a class="button" href="' . esc_url( Admin::url( Admin::HOME, array( 'view' => 'rules', 'goal' => $gid ) ) ) . '">Rules</a> ';
|
||||
@@ -90,6 +90,7 @@ final class GoalsPage {
|
||||
echo '<tr><th scope="row"><label for="sg_start">Starts</label></th><td><input type="datetime-local" id="sg_start" name="starts_at" value="' . esc_attr( $fmt( $g['starts_at'] ?? null ) ) . '"> <span class="description">Optional. Your site time zone. Empty = starts immediately.</span></td></tr>';
|
||||
echo '<tr><th scope="row"><label for="sg_end">Ends</label></th><td><input type="datetime-local" id="sg_end" name="ends_at" value="' . esc_attr( $fmt( $g['ends_at'] ?? null ) ) . '"> <span class="description">Optional. Donations stop after this time.</span></td></tr>';
|
||||
echo '<tr><th scope="row">Fees</th><td><label><input type="checkbox" name="counts_fees" value="1"' . checked( ! empty( $g['counts_fees'] ), true, false ) . '> Count fees covered by donors towards the goal</label><p class="description">Off (recommended): only the amount the donor chose counts, so a $10 donation always adds $10 even if they also covered the fee.</p></td></tr>';
|
||||
echo '<tr><th scope="row">End at target</th><td><label><input type="checkbox" name="close_at_target" value="1"' . checked( ! empty( $g['close_at_target'] ), true, false ) . '> Close this goal to donations when the target is reached</label><p class="description">When the raised total reaches or goes over the target, the goal is marked complete and the donation page stops taking donations to it. Donations already in checkout still complete. You can reopen it with "Reopen" (raise the target first if you want more donations: a reopened goal that is still at or over its target closes again after the next donation).</p></td></tr>';
|
||||
echo '</table><p><button class="button button-primary">' . ( $g ? 'Save goal' : 'Create goal' ) . '</button> <a class="button" href="' . esc_url( Admin::url() ) . '">Cancel</a></p></form>';
|
||||
Admin::close();
|
||||
}
|
||||
@@ -131,7 +132,7 @@ final class GoalsPage {
|
||||
if ( $start && $end && strtotime( $end . ' UTC' ) <= strtotime( $start . ' UTC' ) ) {
|
||||
Admin::redirect( $back, 'error', 'The end must be after the start.' );
|
||||
}
|
||||
$data = array( 'title' => $title, 'target_minor' => $tgt, 'starts_at' => $start, 'ends_at' => $end, 'counts_fees' => empty( $post['counts_fees'] ) ? 0 : 1 );
|
||||
$data = array( 'title' => $title, 'target_minor' => $tgt, 'starts_at' => $start, 'ends_at' => $end, 'counts_fees' => empty( $post['counts_fees'] ) ? 0 : 1, 'close_at_target' => \StreamGoals\Core\GoalTargetPolicy::flagFromPost( $post['close_at_target'] ?? null ) );
|
||||
if ( $id ) {
|
||||
Store::goals()->update( $id, $data );
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace StreamGoals\Core;
|
||||
/** $wpdb-backed CRUD for sg_goals. Requires live WordPress. */
|
||||
final class GoalRepository {
|
||||
|
||||
private const FIELDS = array( 'title' => '%s', 'target_minor' => '%d', 'currency' => '%s', 'status' => '%s', 'starts_at' => '%s', 'ends_at' => '%s', 'counts_fees' => '%d' );
|
||||
private const FIELDS = array( 'title' => '%s', 'target_minor' => '%d', 'currency' => '%s', 'status' => '%s', 'starts_at' => '%s', 'ends_at' => '%s', 'counts_fees' => '%d', 'close_at_target' => '%d' );
|
||||
|
||||
private \wpdb $db;
|
||||
|
||||
@@ -21,7 +21,7 @@ final class GoalRepository {
|
||||
/** @return int new goal id */
|
||||
public function create( array $data ): int {
|
||||
$row = array_intersect_key( $data, self::FIELDS );
|
||||
$row += array( 'status' => 'active', 'currency' => 'USD', 'counts_fees' => 0 );
|
||||
$row += array( 'status' => 'active', 'currency' => 'USD', 'counts_fees' => 0, 'close_at_target' => 0 );
|
||||
$row['created_at'] = gmdate( 'Y-m-d H:i:s' );
|
||||
$this->db->insert( $this->table(), $row );
|
||||
return (int) $this->db->insert_id;
|
||||
@@ -62,9 +62,26 @@ final class GoalRepository {
|
||||
if ( ! $goal ) {
|
||||
return 0;
|
||||
}
|
||||
$col = ! empty( $goal['counts_fees'] ) ? 'total_minor' : 'base_minor'; // whitelisted, not user input
|
||||
$col = GoalTargetPolicy::amountColumn( $goal ); // whitelisted, not user input
|
||||
$d = $this->db->prefix . 'sg_donations';
|
||||
$sum = $this->db->get_var( $this->db->prepare( "SELECT COALESCE(SUM({$col}), 0) FROM {$d} WHERE goal_id = %d AND status = 'completed'", $goalId ) );
|
||||
return (int) $sum;
|
||||
}
|
||||
|
||||
/**
|
||||
* "End at target": if the goal is active, flagged close_at_target and its raised total has reached the
|
||||
* target, set it to 'complete'. The UPDATE is conditional on status = 'active', so concurrent callers
|
||||
* change it once. Idempotent and cheap (one SELECT for non-flagged goals). Returns true if THIS call closed it.
|
||||
*/
|
||||
public function closeIfTargetReached( int $goalId ): bool {
|
||||
$goal = $this->find( $goalId );
|
||||
if ( ! $goal || empty( $goal['close_at_target'] ) || 'active' !== $goal['status'] ) {
|
||||
return false;
|
||||
}
|
||||
if ( ! GoalTargetPolicy::shouldClose( $goal, $this->raised_minor( $goalId ) ) ) {
|
||||
return false;
|
||||
}
|
||||
$n = $this->db->query( $this->db->prepare( "UPDATE {$this->table()} SET status = 'complete' WHERE id = %d AND status = 'active' AND close_at_target = 1", $goalId ) );
|
||||
return 1 === $n;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Core;
|
||||
|
||||
/** Pure rules for "end at target" goals (no WordPress / database access). */
|
||||
final class GoalTargetPolicy {
|
||||
|
||||
/** Donation column summed towards the goal: total (fees included) or base. Whitelisted values only. */
|
||||
public static function amountColumn( array $goal ): string {
|
||||
return ! empty( $goal['counts_fees'] ) ? 'total_minor' : 'base_minor';
|
||||
}
|
||||
|
||||
/** True when the goal should now be auto-closed: flag on, currently active, target set and reached or exceeded. */
|
||||
public static function shouldClose( array $goal, int $raisedMinor ): bool {
|
||||
return ! empty( $goal['close_at_target'] )
|
||||
&& 'active' === ( $goal['status'] ?? '' )
|
||||
&& (int) ( $goal['target_minor'] ?? 0 ) > 0
|
||||
&& $raisedMinor >= (int) $goal['target_minor'];
|
||||
}
|
||||
|
||||
/** True for a goal that is closed to donors because it reached its target (flag on + complete). */
|
||||
public static function isClosedAtTarget( array $goal ): bool {
|
||||
return ! empty( $goal['close_at_target'] ) && 'complete' === ( $goal['status'] ?? '' );
|
||||
}
|
||||
|
||||
/** Checkbox value from a raw form field: 1 when ticked, else 0. */
|
||||
public static function flagFromPost( mixed $raw ): int {
|
||||
if ( is_array( $raw ) || null === $raw ) {
|
||||
return 0;
|
||||
}
|
||||
return in_array( strtolower( trim( (string) $raw ) ), array( '1', 'on', 'true', 'yes' ), true ) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,28 @@ final class DonationStore {
|
||||
} catch ( \Throwable $e ) {
|
||||
error_log( 'StreamGoals: Recorder failed for donation ' . $id . ': ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
|
||||
}
|
||||
self::close_goal_if_target_reached( $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* "End at target": runs after the donation is already completed and counted, so it can never refuse or
|
||||
* undo a capture. Failures are logged and swallowed. Idempotent (atomic UPDATE ... WHERE status='active').
|
||||
*/
|
||||
public static function close_goal_if_target_reached( int $donationId ): void {
|
||||
try {
|
||||
$row = self::find( $donationId );
|
||||
if ( $row && (int) $row->goal_id > 0 ) {
|
||||
( new \StreamGoals\Core\GoalRepository() )->closeIfTargetReached( (int) $row->goal_id );
|
||||
}
|
||||
} catch ( \Throwable $e ) {
|
||||
error_log( 'StreamGoals: end-at-target check failed for donation ' . $donationId . ': ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
|
||||
}
|
||||
}
|
||||
|
||||
/** Goals closed because they reached their target (newest first), for the donor-facing "goal reached" message. @return array[] */
|
||||
public static function reached_goals(): array {
|
||||
global $wpdb;
|
||||
return (array) $wpdb->get_results( 'SELECT * FROM ' . self::t( 'goals' ) . " WHERE status = 'complete' AND close_at_target = 1 ORDER BY id DESC LIMIT 20", ARRAY_A );
|
||||
}
|
||||
|
||||
private static function call_engine( string $method, int $id ): void {
|
||||
|
||||
@@ -84,6 +84,9 @@ final class OrderValidator {
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public static function quote( array $input, array $goal, array $settings, FeeCalculator $fees, int $nowTs ): array {
|
||||
if ( 'complete' === ( $goal['status'] ?? '' ) ) {
|
||||
throw new ValidationException( 'goal_inactive', 'This goal is closed and no longer accepting donations. Thank you for your support!', 409 );
|
||||
}
|
||||
if ( ! self::goalIsOpen( $goal, $nowTs ) ) {
|
||||
throw new ValidationException( 'goal_inactive', 'This goal is not accepting donations.', 409 );
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Rest;
|
||||
|
||||
use StreamGoals\Core\GoalTargetPolicy;
|
||||
use StreamGoals\Core\Money;
|
||||
use StreamGoals\Core\Settings;
|
||||
use StreamGoals\PayPal\CaptureFinalizer;
|
||||
@@ -170,6 +171,11 @@ final class DonateController {
|
||||
);
|
||||
}
|
||||
if ( ! $goals ) {
|
||||
$reached = $pinned ? DonationStore::goal( $pinned ) : null;
|
||||
$reached = $pinned ? ( $reached && GoalTargetPolicy::isClosedAtTarget( $reached ) ) : (bool) DonationStore::reached_goals();
|
||||
if ( $reached ) {
|
||||
return '<p class="sg-donate-unavailable sg-donate-reached">' . esc_html__( 'This goal has been reached - thank you for your support!', 'streamgoals-donate' ) . '</p>';
|
||||
}
|
||||
return '<p class="sg-donate-unavailable">' . esc_html__( 'There is no active goal to donate to right now.', 'streamgoals-donate' ) . '</p>';
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use StreamGoals\Core\FeeCalculator;
|
||||
use StreamGoals\Core\GoalTargetPolicy;
|
||||
use StreamGoals\Core\Settings;
|
||||
use StreamGoals\PayPal\OrderValidator;
|
||||
use StreamGoals\PayPal\ValidationException;
|
||||
|
||||
final class GoalTargetPolicyTest extends TestCase {
|
||||
|
||||
private function goal( array $o = array() ): array {
|
||||
return array_merge( array( 'id' => 3, 'currency' => 'USD', 'status' => 'active', 'target_minor' => 10000, 'close_at_target' => 1, 'counts_fees' => 0, 'starts_at' => null, 'ends_at' => null ), $o );
|
||||
}
|
||||
|
||||
public function test_below_equal_and_over_target(): void {
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal(), 9999 ) );
|
||||
$this->assertTrue( GoalTargetPolicy::shouldClose( $this->goal(), 10000 ) );
|
||||
$this->assertTrue( GoalTargetPolicy::shouldClose( $this->goal(), 25000 ) );
|
||||
}
|
||||
|
||||
public function test_flag_off_or_missing_never_closes(): void {
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal( array( 'close_at_target' => 0 ) ), 99999 ) );
|
||||
$g = $this->goal();
|
||||
unset( $g['close_at_target'] );
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $g, 99999 ) );
|
||||
}
|
||||
|
||||
public function test_only_active_goals_are_closed(): void {
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal( array( 'status' => 'complete' ) ), 20000 ) );
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal( array( 'status' => 'paused' ) ), 20000 ) );
|
||||
}
|
||||
|
||||
public function test_target_zero_never_closes(): void {
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal( array( 'target_minor' => 0 ) ), 0 ) );
|
||||
$this->assertFalse( GoalTargetPolicy::shouldClose( $this->goal( array( 'target_minor' => 0 ) ), 500 ) );
|
||||
}
|
||||
|
||||
public function test_base_vs_total_basis(): void {
|
||||
$this->assertSame( 'base_minor', GoalTargetPolicy::amountColumn( $this->goal() ) );
|
||||
$this->assertSame( 'total_minor', GoalTargetPolicy::amountColumn( $this->goal( array( 'counts_fees' => 1 ) ) ) );
|
||||
}
|
||||
|
||||
public function test_closed_at_target_detection_and_pause_is_not_closed(): void {
|
||||
$this->assertTrue( GoalTargetPolicy::isClosedAtTarget( $this->goal( array( 'status' => 'complete' ) ) ) );
|
||||
$this->assertFalse( GoalTargetPolicy::isClosedAtTarget( $this->goal( array( 'status' => 'paused' ) ) ) );
|
||||
$this->assertFalse( GoalTargetPolicy::isClosedAtTarget( $this->goal( array( 'status' => 'complete', 'close_at_target' => 0 ) ) ) );
|
||||
}
|
||||
|
||||
public function test_checkbox_parsing(): void {
|
||||
$this->assertSame( 1, GoalTargetPolicy::flagFromPost( '1' ) );
|
||||
$this->assertSame( 1, GoalTargetPolicy::flagFromPost( 'on' ) );
|
||||
$this->assertSame( 0, GoalTargetPolicy::flagFromPost( null ) );
|
||||
$this->assertSame( 0, GoalTargetPolicy::flagFromPost( '' ) );
|
||||
$this->assertSame( 0, GoalTargetPolicy::flagFromPost( '0' ) );
|
||||
$this->assertSame( 0, GoalTargetPolicy::flagFromPost( array( '1' ) ) );
|
||||
}
|
||||
|
||||
public function test_new_orders_for_a_closed_goal_get_a_friendly_409(): void {
|
||||
try {
|
||||
OrderValidator::validate( array( 'amount' => '5.00' ), $this->goal( array( 'status' => 'complete' ) ), Settings::defaults(), new FeeCalculator( 349, 49 ), 1800000000 );
|
||||
$this->fail( 'expected refusal' );
|
||||
} catch ( ValidationException $e ) {
|
||||
$this->assertSame( 'goal_inactive', $e->errorCode );
|
||||
$this->assertSame( 409, $e->status );
|
||||
$this->assertStringContainsString( 'Thank you', $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function test_paused_goal_keeps_generic_message(): void {
|
||||
try {
|
||||
OrderValidator::quote( array( 'amount' => '5.00' ), $this->goal( array( 'status' => 'paused' ) ), Settings::defaults(), new FeeCalculator( 349, 49 ), 1800000000 );
|
||||
$this->fail( 'expected refusal' );
|
||||
} catch ( ValidationException $e ) {
|
||||
$this->assertSame( 'This goal is not accepting donations.', $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function test_goal_open_for_active_flagged_goal(): void {
|
||||
$this->assertTrue( OrderValidator::goalIsOpen( $this->goal(), 1800000000 ) );
|
||||
$this->assertFalse( OrderValidator::goalIsOpen( $this->goal( array( 'status' => 'complete' ) ), 1800000000 ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user