/** * {@inheritdoc} */ public function handle(MassActionHandlerArgs $args) { $massAction = $args->getMassAction(); $entityName = $this->actionRepository->getEntityName($args->getDatagrid()); if (!$this->isMassActionEnabled($entityName)) { return $this->getResponse($massAction, 0, 'Action not configured or not allowed'); } $massAction->getOptions()->offsetSet('entityName', $entityName); $entitiesCount = $this->actionRepository->batchUpdate($massAction, $args->getResults(), $args->getData()); return $this->getResponse($massAction, $entitiesCount); }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Field name was not specified with option 'mass_edit_field' * * @throws \Exception */ public function testBatchUpdateNoFieldName() { /** @var MassActionInterface|\PHPUnit_Framework_MockObject_MockObject $massActionMock */ $massActionMock = $this->getMock(MassActionInterface::class); $entityName = 'Test\\Entity'; $options = ActionConfiguration::create(['entityName' => $entityName]); $massActionMock->expects($this->any())->method('getOptions')->will($this->returnValue($options)); /** @var IterableResultInterface|\PHPUnit_Framework_MockObject_MockObject $massActionMock */ $iteratorMock = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\IterableResultInterface'); $data = []; $this->actionRepo->batchUpdate($massActionMock, $iteratorMock, $data); }