public function testShouldSkip()
 {
     $this->assertFalse($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $skipExclusionGroupStrategy = new GroupsExclusionStrategy(array('test1'));
     $this->propertySkipper->registerStrategy($skipExclusionGroupStrategy);
     $this->assertTrue($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $nonSkipExclusionGroupStrategy = new GroupsExclusionStrategy(array('test'));
     $this->propertySkipper->registerStrategy($nonSkipExclusionGroupStrategy);
     $this->assertTrue($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $this->propertySkipper->cleanUpStrategies();
     $this->propertySkipper->registerStrategy($nonSkipExclusionGroupStrategy);
     $this->assertFalse($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $skipExclusionVersionStrategy = new VersionExclusionStrategy('5.5');
     $this->propertySkipper->registerStrategy($skipExclusionVersionStrategy);
     $this->assertTrue($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $nonSkipExclusionVersionStrategy = new VersionExclusionStrategy('5.1');
     $this->propertySkipper->registerStrategy($nonSkipExclusionVersionStrategy);
     $this->assertTrue($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $this->propertySkipper->cleanUpStrategies();
     $this->propertySkipper->registerStrategy($nonSkipExclusionGroupStrategy);
     $this->assertFalse($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $this->propertySkipper->registerStrategy($skipExclusionGroupStrategy);
     $this->assertTrue($this->propertySkipper->shouldSkip($this->propertyMetadata));
     $this->propertySkipper->cleanUpStrategies();
     $this->assertFalse($this->propertySkipper->shouldSkip($this->propertyMetadata));
 }
 /**
  * {@inheritDoc}
  *
  * @param mixed $data
  * @param object $object
  */
 public function toObject(array $data, $object)
 {
     $className = $this->getFullClassName($object);
     $metadata = $this->metadataFactory->getMetadataForClass($className);
     $unserializedProperties = 0;
     foreach ($metadata->getProperties() as $property) {
         if (!$property->isExpose() || $this->propertySkipper->shouldSkip($property)) {
             if ($this->isMediumStrictUnserializeMode() && array_key_exists($property->getSerializedName(), $data)) {
                 throw new InvalidArgumentException(sprintf('%s extra field', $property->getSerializedName()));
             }
             continue;
         }
         if (!array_key_exists($property->getSerializedName(), $data)) {
             if ($this->isStrictUnserializeMode()) {
                 throw new InvalidArgumentException(sprintf('%s field is lost', $property->getSerializedName()));
             }
             continue;
         }
         $value = $this->handleValue($data[$property->getSerializedName()], $property, self::DIRECTION_UNSERIALIZE, $object);
         if ($value === $object) {
             throw new RecursionException(sprintf('Invalid self reference detected. %s::%s', $className, $property->getName()));
         }
         $this->involveValue($object, $property, $value);
         $unserializedProperties++;
     }
     if ($this->isMediumStrictUnserializeMode() && $unserializedProperties !== count($data)) {
         throw new InvalidArgumentException('Wrong number of fields in the deserialized data');
     }
     return $object;
 }