예제 #1
0
파일: Runner.php 프로젝트: cti/scheduler
 function init(Init $init, Master $master, DBAL $adapter)
 {
     $system = $master->getJobs()->findOne(array('system' => true));
     $now = $adapter->fetchNow();
     if ($system->getActiveTask()) {
         $message = sprintf("Task %s is running", $system->getActiveTask()->getIdTask());
         if ($this->createSystemFail) {
             $task = $system->createActiveTask()->setDtEnd($now)->setStatus('F')->save();
             $task->log($message);
         }
         throw new \Exception($message);
     }
     $task = $system->createActiveTask();
     $tasks = $master->getTasks()->findWhere('dt_scheduled < :now and status = :status', array('now' => $now, 'status' => 'N'));
     if (count($tasks)) {
         $task->log(sprintf('Found %s task(s).', count($tasks)));
         foreach ($tasks as $task) {
             //
         }
     } else {
         $task->log('No tasks found');
     }
     $task->setDtEnd($adapter->fetchNow(true))->setStatus('C')->save();
 }
예제 #2
0
파일: LinkTest.php 프로젝트: cti/storage
 public function testManyToManyDelete()
 {
     \DatabaseManager::generateFakeRecords();
     $admin = $this->personRepository->findOne(array('login' => 'admin'));
     $backend = $this->moduleRepository->findOne(array('name' => 'Backend'));
     $admin->addModuleDeveloperLink($backend);
     $links = $admin->getModuleDeveloperLinks();
     $this->assertCount(1, $links);
     $link = $links[0];
     $link->delete();
     $links = $admin->getModuleDeveloperLinks();
     $this->assertCount(0, $links);
     $rows = $this->dbal->fetchAll("select * from module_developer_link");
     $this->assertCount(1, $rows);
     $now = $this->dbal->fetchNow();
     $this->assertLessThanOrEqual(strtotime($now), $rows[0]['v_end']);
     \DatabaseManager::clearTables();
 }
예제 #3
0
 public function testFind()
 {
     \DatabaseManager::generateFakeRecords();
     $admin = $this->personRepository->findOne(array('login' => 'admin'));
     $this->assertNotNull($admin);
     $this->assertEquals('admin', $admin->getLogin());
     $persons = $this->personRepository->findAll();
     /**
      * There are 3 rows in table, but one of them have 2 versions
      * Need to fetch 2 actual persons
      */
     $this->assertCount(2, $persons, "Old model in result");
     /**
      * Test getting of old person model
      */
     $pastTime = date('Y-m-d H:i:s', strtotime($this->dbal->fetchNow()) - 6000);
     $models = $this->personRepository->findAll(array('login' => 'user'), $pastTime);
     $this->assertCount(1, $models);
     $oldPerson = $models[0];
     $this->assertEquals('321', $oldPerson->getSalt());
     \DatabaseManager::clearTables();
 }