Esempio n. 1
0
 /**
  * @dataProvider getTestData
  *
  * @param mixed      $value
  * @param string     $serialized
  * @param mixed|null $expected
  */
 public function testSerialize($value, $serialized, $expected = null)
 {
     $assert = is_object($value) ? 'assertEquals' : 'assertSame';
     if (null === $expected) {
         $expected = $value;
     }
     $this->{$assert}($serialized, $this->serializer->serialize($value));
     $this->{$assert}($expected, $this->serializer->deserialize($serialized));
 }
Esempio n. 2
0
 protected function setUp()
 {
     /** @var DriverInterface $driver */
     $this->driver = $this->getMockBuilder(DriverInterface::class)->getMockForAbstractClass();
     /** @var SerializerInterface $serializer */
     $this->serializer = $this->getMockBuilder(SerializerInterface::class)->getMockForAbstractClass();
     $this->serializer->expects($this->any())->method('serialize')->will($this->returnArgument(0));
     $this->serializer->expects($this->any())->method('deserialize')->will($this->returnArgument(0));
     $this->cache = new Cache($this->driver, $this->serializer);
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function set($key, $value, $ttl = 0)
 {
     $value = $this->serializer->serialize($value);
     return $this->driver->set($key, $value, $ttl);
 }