/**
  * @param \_OurBrand_\Quiz\Domain\Model\Exercises\MatchPictureInPictureExercise $exercise
  * @return void
  */
 public function updateAction($exercise)
 {
     if ($this->request->hasArgument('draggableShapeData')) {
         $shapes = array();
         foreach ($this->request->getArgument('draggableShapeData') as $shape) {
             // Insert the image resource in the array
             $shape['imageObj'] = $this->persistenceManager->getObjectByIdentifier($shape['uuid'], '\\_OurBrand_\\Quiz\\Domain\\Model\\ImageResource');
             $shapes[] = $shape;
         }
         $exercise->addShapesFromArray($shapes);
     }
     if ($this->request->hasArgument('mainImage')) {
         $imageObj = $this->persistenceManager->getObjectByIdentifier($this->request->getArgument('mainImage'), '\\_OurBrand_\\Quiz\\Domain\\Model\\ImageResource');
         if ($imageObj !== null) {
             $exercise->addMainImage($imageObj);
         }
     }
     if ($this->request->hasArgument('quiz')) {
         $this->updateQuizBeforeUpdatingExercise($exercise->getQuiz(), $this->request->getArgument('quiz'));
     }
     if (!$this->request->hasArgument('json')) {
         $this->forward('update', 'exercise', null, array('exercise' => $exercise));
     }
     $this->forward('updateSilent', 'exercise', null, array('exercise' => $exercise, 'json' => $this->request->getArgument('json')));
 }
 /**
  * @dataProvider shapesDataProvider
  * @param $shapeArray
  * @param $assertions
  */
 public function testPostClone($shapeArray, $assertions)
 {
     $exercise = new MatchPictureInPictureExercise();
     $this->assertNull($exercise->addShapesFromArray($shapeArray));
     // mainImage
     $mockMainImage = $this->getMock('_OurBrand_\\Quiz\\Domain\\Model\\Exercises\\MatchPictureInPictureMainImage');
     $collection = new \Doctrine\Common\Collections\ArrayCollection();
     $collection->add($mockMainImage);
     $exercise->setMainImageCollection($collection);
     $mockImage = $this->getMock('\\_OurBrand_\\Quiz\\Domain\\Model\\ImageResource', array('clear'));
     $mockMainImage->expects($this->any())->method('clear')->will($this->returnValue(null));
     $this->assertNull($exercise->addMainImage($mockImage), 'addMainImage() must have an imageResource object given');
     // shapes
     $mockShape = $this->getMock('_OurBrand_\\Quiz\\Domain\\Model\\Exercises\\MatchPictureShape', array('getImageSrc', 'getType', 'getActive'));
     $this->assertNull($exercise->addShape($mockShape), 'addShape()');
     // active shape
     $mockShape = $this->getMock('_OurBrand_\\Quiz\\Domain\\Model\\Exercises\\MatchPictureShape', array('getImageSrc', 'getType', 'getActive'));
     $this->assertNull($exercise->addShape($mockShape), 'addShape()');
     $exerciseClone = clone $exercise;
     $this->assertNull($exerciseClone->postClone(), '$clone->postClone()');
     // check that the cloned data are the same
     // Test mainImage
     $this->assertCount(count($exercise->getMainImageCollection()), $exerciseClone->getMainImageCollection(), 'cloned getMainImageCollection() does not match');
     // Test shapes
     $this->assertCount(count($exercise->getShapes()), $exerciseClone->getShapes(), 'cloned getShapes() does not match');
 }