$dates = $scheduler->dates();
    $latestDate = $dates[$latest];
    if ($latestDate != $targetDate) {
        $message = sprintf($message, $target, $latest, $time);
        echo "Failed: {$date} -> {$latestDate} != {$targetDate} - {$message}\n";
    } else {
        if ($showSuccess) {
            echo "Success: {$date} -> {$latestDate} == {$targetDate} - {$message}\n";
        }
    }
}
$scheduler = new BfoxPlanScheduler();
$scheduler->setStartDate('2011-08-16');
$scheduler->pushNumDates(4);
$ans = array('2011-08-16', '2011-08-17', '2011-08-18', '2011-08-19');
assertArrays($ans, $scheduler->dates());
assertLatest($scheduler, '2011-08-15', '2011-08-16', 'Dates before a plan begins should point to the first reading');
assertLatest($scheduler, '2011-08-16', '2011-08-16', 'The date of the first reading');
assertLatest($scheduler, '2011-08-17', '2011-08-17', 'The date of the second reading');
$scheduler->setFrequency('monthly');
$scheduler->pushNumDates(4);
$ans = array_merge($ans, array('2011-08-20', '2011-09-20', '2011-10-20', '2011-11-20'));
assertArrays($ans, $scheduler->dates());
assertLatest($scheduler, '2011-08-20', '2011-08-20', 'The first date of the month');
assertLatest($scheduler, '2011-09-19', '2011-08-20', 'The last date of the month should still have the old reading from the beginning of the month');
assertLatest($scheduler, '2011-09-20', '2011-09-20', 'The first date of the new month');
$scheduler->setFrequency('weekly');
$scheduler->pushNumDates(4);
$ans = array_merge($ans, array('2011-12-20', '2011-12-27', '2012-01-03', '2012-01-10'));
assertArrays($ans, $scheduler->dates());
$scheduler->setFrequency('daily');