Ejemplo n.º 1
0
 public function testValueFetchExisting()
 {
     $function = $this->getMockBuilder('stdObject')->setMethods(['__invoke'])->getMock();
     $function->expects($this->never())->method('__invoke');
     $value = new Value($function, 'key', 1);
     $storageStrategy = $this->getStorageStrategy();
     $storageStrategy->expects($this->once())->method('getRaw')->with('key')->willReturn('test');
     $valueStorage = new ValueStorage($storageStrategy);
     $data = $valueStorage->get($value);
     $this->assertEquals('test', $data);
 }
Ejemplo n.º 2
0
 public function testValueGetExisting()
 {
     $value = $this->getMockBuilder('SFM\\Value\\ValueInterface')->disableOriginalConstructor()->setMethods(['getKey', 'getValue', 'getExpiration'])->getMock();
     $value->expects($this->any())->method('getKey')->willReturn('test');
     $value->expects($this->never())->method('getValue');
     $value->expects($this->never())->method('getExpiration');
     $storageStrategy = $this->getMockBuilder('SFM\\Value\\ValueStorageStrategyInterface')->disableOriginalConstructor()->setMethods(['deleteRaw', 'getRaw', 'setRaw'])->getMock();
     $storageStrategy->expects($this->once())->method('getRaw')->with('test')->willReturn('value');
     $storageStrategy->expects($this->never())->method('setRaw');
     $storage = new ValueStorage($storageStrategy);
     $data = $storage->get($value);
     $this->assertEquals('value', $data);
 }