/** * Create new task * @return AM_Task_Worker_Notification_Planner */ public static function createTask($options) { $oIssue = AM_Model_Db_Table_Abstract::factory('issue')->findOneBy('id', $options['issue_id']); /* @var $oIssue AM_Model_Db_Issue */ if (is_null($oIssue)) { throw new AM_Task_Worker_Exception('Issue not found'); } $iApplicationId = $oIssue->getApplication()->id; if (empty($iApplicationId)) { throw new AM_Task_Worker_Exception('Wrong parameters were given'); } $oApplication = AM_Model_Db_Table_Abstract::factory('application')->findOneBy('id', $iApplicationId); if (!empty($oApplication->push_apple_enabled)) { $oTaskPlanner = new AM_Task_Worker_Notification_Planner_Apple(); $oTaskPlanner->setOptions($options)->create(); } if (!empty($oApplication->push_boxcar_enabled)) { $oTaskSender = new AM_Task_Worker_Notification_Planner_Boxcar(); $oTaskSender->setOptions($options)->create(); } }
public function testShouldPlaneNotification() { //GIVEN $oWorker = new AM_Task_Worker_Notification_Planner_Apple(); $oWorker->addOption('issue_id', 1); $oWorker->addOption('message', 'Test message'); $oWorker->addOption('badge', 0); $oWorker->create(); //WHEN try { $oWorker->run(); } catch (Exception $oException) { $this->fail($oException->getMessage()); } //THEN $oGivenDataSet = $this->getConnection()->createQueryTable('task', 'SELECT id, task_type_id, status, options FROM task ORDER BY id'); $oExpectedDataSet = $this->createFlatXMLDataSet(dirname(__FILE__) . '/_dataset/ApnsWorkerPlannerSuccessTest.xml')->getTable('task'); $this->assertTablesEqual($oExpectedDataSet, $oGivenDataSet); }