function testProcesses()
 {
     SweteDb::q('delete from background_processes');
     require_once 'inc/BackgroundProcess.php';
     $process = new BackgroundProcess();
     $this->assertEquals(null, $process->getProcessId());
     $this->assertEquals(false, $process->isClean());
     $process->save();
     $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
     $this->assertTrue($prec instanceof Dataface_Record);
     $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
     $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
     $this->assertEquals(0, intval($prec->val('running')));
     $this->assertEquals(0, intval($prec->val('complete')));
     $this->assertEquals(0, intval($prec->val('error')));
     $process->start();
     $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
     $this->assertTrue($prec instanceof Dataface_Record);
     $this->assertTrue(isset($prec));
     if ($prec) {
         $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
         $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
         $this->assertEquals(0, intval($prec->val('running')));
         $this->assertEquals(1, intval($prec->val('complete')));
         $this->assertEquals(0, intval($prec->val('error')));
     }
     $process = new BackgroundProcess();
     $this->assertEquals(null, $process->getProcessId());
     $this->assertEquals(false, $process->isClean());
     $process->save();
     $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
     $this->assertTrue($prec instanceof Dataface_Record);
     $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
     $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
     $this->assertEquals(0, intval($prec->val('running')));
     $this->assertEquals(0, intval($prec->val('complete')));
     $this->assertEquals(0, intval($prec->val('error')));
     BackgroundProcess::runProcess($process->getProcessId());
     $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
     $this->assertTrue($prec instanceof Dataface_Record);
     $this->assertTrue(isset($prec));
     if ($prec) {
         $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
         $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
         $this->assertEquals(0, intval($prec->val('running')));
         $this->assertEquals(1, intval($prec->val('complete')));
         $this->assertEquals(0, intval($prec->val('error')));
     }
     $process = new BackgroundProcess();
     $this->assertEquals(null, $process->getProcessId());
     $this->assertEquals(false, $process->isClean());
     $process->save();
     $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
     $this->assertTrue($prec instanceof Dataface_Record);
     $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
     $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
     $this->assertEquals(0, intval($prec->val('running')));
     $this->assertEquals(0, intval($prec->val('complete')));
     $this->assertEquals(0, intval($prec->val('error')));
     $res = BackgroundProcess::runProcesses();
     $this->assertTrue($res);
     if ($res) {
         $prec = df_get_record('background_processes', array('process_id' => '=' . $process->getProcessId()));
         $this->assertTrue($prec instanceof Dataface_Record);
         $this->assertTrue(isset($prec));
         if ($prec) {
             $this->assertEquals($process->getProcessId(), $prec->val('process_id'));
             $this->assertEquals('BackgroundProcess', $prec->val('process_class'));
             $this->assertEquals(0, intval($prec->val('running')));
             $this->assertEquals(1, intval($prec->val('complete')));
             $this->assertEquals(0, intval($prec->val('error')));
         }
     }
 }