Esempio n. 1
0
 public function __construct(MongoDB $db)
 {
     $this->db = $db;
     $this->jobs = new Job\Repository($db);
     $this->workers = new Worker\Repository($db, $this);
     $this->lock = MongoLock::forProgram('RECRUITER', $db->selectCollection('metadata'));
     $this->eventDispatcher = new EventDispatcher();
 }
 /**
  * @expectedException Onebip\Concurrency\LockNotAvailableException
  * @expectedExceptionMessage ws-a-25:42 cannot acquire a lock for the program windows_defrag
  */
 public function testAnExpiredLockCannotBeRefreshed()
 {
     Phake::when($this->clock)->current()->thenReturn(new DateTime('2014-01-01T00:00:00Z'))->thenReturn(new DateTime('2014-01-01T02:00:00Z'));
     $first = new MongoLock($this->lockCollection, 'windows_defrag', 'ws-a-25:42', $this->clock);
     $first->acquire();
     $second = new MongoLock($this->lockCollection, 'windows_defrag', 'ws-a-25:42', $this->clock);
     $second->refresh();
 }