public function testIdGeneration()
 {
     $redis = $this->prophesize("Corley\\OAuth2\\Server\\Storage\\Redis\\RedisMock");
     $redis->transaction()->willReturn($redis->reveal());
     $redis->incr("oauth:ids")->willReturn($redis->reveal());
     $redis->execute()->willReturn([1]);
     $idGen = new IdGenerator($redis->reveal());
     $id = $idGen->createId();
     $this->assertInternalType("int", $id);
     $this->assertSame(1, $id);
 }
Пример #2
0
 /**
  * Push multiple jobs to queue
  *
  * Format:
  * $jobs = [
  *  [
  *      'class' => 'SomeClass',
  *      'args' => array(),
  *      'retry' => false,
  *      'at' => microtime(true)
  *  ]
  * ];
  *
  * @param array  $jobs
  * @param string $queue
  * @return string
  * @throws exception Exception
  */
 public function pushBulk($jobs = [], $queue = self::QUEUE)
 {
     $ids = [];
     foreach ($jobs as $job) {
         if (!isset($job['class'])) {
             throw new Exception('pushBulk: each job needs a job class');
         }
         if (!isset($job['args']) || !is_array($job['args'])) {
             throw new Exception('pushBulk: each job needs args');
         }
         $retry = isset($job['retry']) ? $job['retry'] : true;
         $doAt = isset($job['at']) ? $job['at'] : null;
         $jobId = $this->idGenerator->generate();
         array_push($ids, $jobId);
         $this->atomicPush($jobId, $job['class'], $job['args'], $queue, $retry, $doAt);
     }
     return $ids;
 }
Пример #3
0
 public function generateIds($count = 1)
 {
     return $this->id_generator->generateIds($this->connection, $count);
 }
Пример #4
0
 /** @brief Retrieves filter identifier.
  *
  * Internal use only.
  * @return instance identifier.
  */
 public final function get_id()
 {
     return IdGenerator::from_values($this->local_name, $this->ns_uri);
 }