Example #1
0
 /**
  * Test: Cas set a key value pair.
  *
  * @author Benjamin Carl <*****@*****.**>
  * @return void
  * @access protected
  */
 public function testCasSetAKeyValuePair()
 {
     // Random 32 Bit decimal (wrong CAS emulate)
     srand(microtime(true));
     $value = rand(0, 65535);
     $this->assertFalse($this->client->cas($value, $this->key, $value));
     $this->assertTrue($this->client->set($this->key, $this->value));
     $value = $this->client->gets(array($this->key), true);
     $this->assertTrue($this->client->cas($value[$this->key]['meta']['cas'], $this->key, 'bar'));
     $this->assertArrayHasKey($this->key, $this->client->gets(array($this->key)));
     $this->assertFalse($this->client->cas($value[$this->key]['meta']['cas'], $this->key, $this->value));
     $this->assertEquals('bar', $this->client->get($this->key));
 }