/**
  * Tests all cases when GenerateUniqueKey is true
  */
 public function testGenerateUniqueKeyTrue()
 {
     $generator = new UniqueJobIdentifierGenerator(true);
     $unique = 'c1af4ce5c9773ce30d8cc6d1e0e7d699';
     $this->assertEquals('uniqueValue', $generator->generateUniqueKey('name', 'params', 'uniqueValue', 'method'));
     $this->assertEquals($unique, $generator->generateUniqueKey('name', 'params', false, 'method'));
     $this->assertEquals($unique, $generator->generateUniqueKey('name', 'params', null, 'method'));
     $this->assertEquals($unique, $generator->generateUniqueKey('name', 'params', '', 'method'));
 }
Exemplo n.º 2
0
 /**
  * Adds a task into the structure of tasks with included type of call
  *
  * @param string $name    A GermanBundle registered function to be executed
  * @param string $params  Parameters to send to task as string
  * @param Mixed  $context Application context to associate with a task
  * @param string $unique  A unique ID used to identify a particular task
  * @param string $method  Method to perform
  *
  * @return GearmanClient Return this object
  */
 protected function enqueueTask($name, $params, &$context, $unique, $method)
 {
     $contextReference = array('context' => &$context);
     $task = array('name' => $name, 'params' => $params, 'context' => $contextReference, 'unique' => $this->uniqueJobIdentifierGenerator->generateUniqueKey($name, $params, $unique, $method), 'method' => $method);
     $this->addTaskToStructure($task);
     return $this;
 }