/** * @param \Ingenerator\RunSingle\PdoDatabaseObject $db_object * @param \Psr\Log\LoggerInterface $logger */ function let($db_object, $logger) { $db_object->execute(self::INSERT_LOCK_SQL, array(':task_name' => self::TASK_NAME, ':timeout' => self::TIMEOUT, ':timestamp' => self::FAKE_TIMESTAMP, ':lock_holder' => self::FAKE_LOCK_HOLDER))->willReturn(); $db_object->get_db_table_name()->willReturn('locks'); $db_object->fetch_all(self::SELECT_LOCK_SQL, array(':task_name' => self::TASK_NAME, ':current_timestamp' => self::FAKE_TIMESTAMP))->willReturn(); $this->subject->beConstructedWith($db_object); $logger->debug(Argument::any())->willReturn(); $logger->warning(Argument::any())->willReturn(); $this->subject->set_time_provider(__CLASS__ . '::faketime'); }
/** * Return a list of locks. * * @return array */ public function list_locks() { $result = $this->db_object->fetch_all('SELECT * FROM ' . $this->db_object->get_db_table_name(), array()); $locks = array(); if ($result) { foreach ($result as $result_item) { $locks[] = $this->build_lock_object($result_item); } } return $locks; }