public function testDeserializationContextConversion()
 {
     $context = new Context();
     $context->setAttribute('bar', 'foo');
     $context->setAttribute('version', 1);
     $context->addGroups(['e', 'f']);
     $context->setVersion(1.4);
     $context->setMaxDepth(10);
     $context->setSerializeNull(false);
     $JMSContext = $this->adapter->convertDeserializationContext($context);
     $this->assertInstanceOf(\JMS\Serializer\DeserializationContext::class, $JMSContext);
     $this->assertEquals('foo', $JMSContext->attributes->get('bar')->get());
     $this->assertEquals(['e', 'f'], $JMSContext->attributes->get('groups')->get());
     $this->assertEquals(1.4, $JMSContext->attributes->get('version')->get());
     $this->assertEquals(false, $JMSContext->shouldSerializeNull());
 }
 public function testContextConversion()
 {
     $context = new Context();
     $context->setAttribute('groups', array('d'));
     $context->setAttribute('foo', 'bar');
     $context->setAttribute('version', 1);
     $context->addGroups(array('a', 'b', 'c'));
     $context->setVersion(1.3);
     $context->setMaxDepth(10);
     $context->setSerializeNull(false);
     $serializationContext = $this->adapter->convertSerializationContext($context);
     $this->assertTrue(is_array($serializationContext));
     $this->assertEquals(array('groups' => array('a', 'b', 'c'), 'foo' => 'bar', 'version' => 1.3, 'maxDepth' => 10, 'serializeNull' => false), $serializationContext);
     $deserializationContext = $this->adapter->convertDeserializationContext($context);
     $this->assertTrue(is_array($deserializationContext));
     $this->assertEquals(array('groups' => array('a', 'b', 'c'), 'foo' => 'bar', 'version' => 1.3, 'maxDepth' => 10), $deserializationContext);
 }
 /**
  * @param Context $context
  * @param array   $options
  */
 protected function configureContext(Context $context, array $options)
 {
     foreach ($options as $key => $value) {
         if ($key == 'groups') {
             $context->addGroups($options['groups']);
         } elseif ($key == 'version') {
             $context->setVersion($options['version']);
         } elseif ($key == 'maxDepth') {
             $context->setMaxDepth($options['maxDepth']);
         } elseif ($key == 'serializeNull') {
             $context->setSerializeNull($options['serializeNull']);
         } else {
             $context->setAttribute($key, $value);
         }
     }
 }