/**
 * Execute the next chunk/step of the donation receipt run
 */
function civicrm_api3_donation_receipt_engine_next($params)
{
    // first, check if the snapshot ID is there
    if (empty($params['sid'])) {
        return civicrm_api3_create_error(ts("No 'sid' parameter given.", array('domain' => 'de.systopia.donrec')));
    }
    // Init the engine
    $sid = (int) $params['sid'];
    $engine = new CRM_Donrec_Logic_Engine();
    $engine_error = $engine->init($sid, $params);
    if ($engine_error) {
        return civicrm_api3_create_error($engine_error);
    }
    // just run the next step
    $result = $engine->nextStep();
    // and return the result
    return civicrm_api3_create_success($result);
}
Esempio n. 2
0
 public function testEngineMultiExport()
 {
     // create a new snapshot
     $contributions = $this->generateContributions(6);
     $result = CRM_Donrec_Logic_Snapshot::create($contributions, 1);
     $snapshot = $result['snapshot'];
     // engine setup parameters
     $sid = $snapshot->getId();
     $parameters = array();
     $parameters['test'] = 1;
     $parameters['bulk'] = 0;
     $parameters['exporters'] = 'Dummy,SecondDummy';
     // let's try to start it
     $engine = new CRM_Donrec_Logic_Engine();
     $engine_error = $engine->init($sid, $parameters, TRUE);
     $this->assertEquals(FALSE, $engine_error);
     $ctr = 0;
     foreach ($contributions as $id) {
         $stats = $engine->nextStep();
         $ctr++;
         $this->assertDBQuery('TEST', sprintf("SELECT `status` FROM `donrec_snapshot` WHERE `contribution_id` = %d;", $id));
         $this->assertDBQuery('{"Dummy":{"test":"Dummy was here!"},"SecondDummy":{"test":"2nd Dummy was here!"}}', sprintf("SELECT `process_data` FROM `donrec_snapshot` WHERE `contribution_id` = %d;", $id));
         $this->assertEquals($stats['count'], 6);
         $this->assertEquals($stats['completed_test'], $ctr);
     }
 }