public function testList()
 {
     $notifFactory = new NotifFactory();
     $notifList = array();
     for ($i = 0; $i < 3; $i++) {
         $rawData = array('appid' => 111, 'snsid' => '675097095878591' . '_' . $i, 'feature' => 'feature111', 'template' => 'template111', 'trackRef' => 'ref111', 'fireTime' => time() + 100, 'fired' => false);
         $notifList[] = $notifFactory->make($rawData);
     }
     $fbNotifFactory = new FBNotifFactory();
     $fbNotifList = $fbNotifFactory->makeList($notifList);
     static::assertTrue(is_array($fbNotifList) && count($fbNotifList) === count($notifList));
     $fbNotifList2 = array();
     foreach ($notifList as $notif) {
         $fbNotifList2[] = $fbNotifFactory->make($notif);
     }
     static::assertEquals($fbNotifList, $fbNotifList2);
 }
 * User: Jiang Yu
 * Date: 2015/06/24
 * Time: 7:45 PM
 */
use Application\Facade;
use FBGateway\FBNotifFactory;
use Persistency\Facebook\GatewayPersistBuilder;
use Repository\FBGatewayRepo;
require __DIR__ . '/../bootstrap.php';
$options = getopt('v', ['fireTime:', 'no-debug']);
$verbose = isset($options['v']);
$fireTime = isset($options['fireTime']) ? (int) $options['fireTime'] : time();
$debugEnabled = !isset($options['no-debug']);
$timer = (new \Timer\Generator())->shootThenGo($fireTime, time() + 3600);
$fbGatewayConfig = Facade::getInstance()->getFBGatewayOptions();
$gunner = (new GatewayPersistBuilder())->build($fbGatewayConfig);
$fbNotifFactory = new FBNotifFactory();
$fireMachine = new FBGatewayRepo($gunner, $fbNotifFactory);
$notifListRepo = Facade::getInstance()->getNotifListRepo();
foreach ($timer as $timestamp) {
    $pendingList = $notifListRepo->getPending($timestamp);
    if (count($pendingList) === 0) {
        continue;
    }
    if ($verbose) {
        dump(date('Ymd H:i:s') . ' pending notifications = ' . count($pendingList));
    }
    $fbNotifList = $fbNotifFactory->makeList($pendingList);
    $fireMachine->burst($fbNotifList);
    $notifListRepo->markFired($pendingList);
}