public function testDenormalizeWithItemType()
 {
     $format = null;
     $context = array();
     $fooEntity = new \stdClass();
     $barEntity = new \stdClass();
     $this->serializer->expects($this->exactly(2))->method('denormalize')->will($this->returnValueMap(array(array('foo', 'ItemType', $format, $context, $fooEntity), array('bar', 'ItemType', $format, $context, $barEntity))));
     $this->assertEquals(new ArrayCollection(array($fooEntity, $barEntity)), $this->normalizer->denormalize(array('foo', 'bar'), 'ArrayCollection<ItemType>', $format, $context));
 }
 /**
  * Denormalizes and sets primary to first element
  *
  * @param mixed $data
  * @param string $class
  * @param null $format
  * @param array $context
  * @return ArrayCollection
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     $result = parent::denormalize($data, $class, $format, $context);
     $primary = true;
     /** @var $item PrimaryItem */
     foreach ($result as $item) {
         $item->setPrimary($primary);
         $primary = false;
     }
     return $result;
 }