/** * @dataProvider stateProvider * @param string $state */ public function testHandleVisibleState($state) { $fieldName = 'visible_on_front'; $this->recordToHandle->expects($this->once())->method('getFields')->will($this->returnValue([$fieldName])); $this->recordToHandle->expects($this->any())->method('getValue')->will($this->returnCallback(function ($value) use($state) { switch ($value) { case 'status': return 'some_my_status'; break; case 'state': return $state; break; } return ''; })); $this->recordToHandle->expects($this->once())->method('setValue')->with($fieldName, 1); $handler = new SetVisibleOnFront(); $handler->setField($fieldName); $handler->handle($this->recordToHandle, $this->oppositeRecord); }