/** * @param $entity * @param $content * * @return array */ protected function processUpdate($entity, $content) { $form = $this->formBuilder->build($entity, $content); $data = $this->presetData($entity); foreach ($content as $fieldName => $fieldValue) { $fieldValue = $this->cleanupValue($fieldValue); $data[$fieldName] = $this->prepareValueForForm($entity, $fieldName, $fieldValue); } $changeSet = $this->handler->process($entity, $form, $data, 'PATCH'); return array($form, $changeSet); }
public function testProcessValid() { $entity = new SomeEntity(); $form = $this->getMock('Symfony\\Component\\Form\\FormInterface'); $data = ['a' => '1', 'b' => '2']; $method = 'PATCH'; $this->processor->expects($this->once())->method('preProcess')->with($entity); $form->expects($this->once())->method('setData')->with($entity); $form->expects($this->once())->method('submit')->with($data); $form->expects($this->once())->method('isValid')->willReturn(true); $this->processor->expects($this->once())->method('beforeProcess')->with($entity); $this->processor->expects($this->once())->method('afterProcess')->with($entity); $this->processor->expects($this->never())->method('invalidateProcess')->with($entity); $this->initManager(); $this->assertEquals(['fields' => ['a' => '1', 'b' => '2']], $this->handler->process($entity, $form, $data, $method)); }