/** * @param $timeAndOffset array * @param $expected array * @return void * @dataProvider dataProviderTimeAndOffsets */ public function testHandle($timeAndOffset, $expected) { list($value, $offset, $dataType) = array_values($timeAndOffset); $newValue = $expected['datetime']; $fieldName = 'fieldname'; /** @var \Migration\ResourceModel\Record|\PHPUnit_Framework_MockObject_MockObject $recordToHandle */ $recordToHandle = $this->getMock('Migration\\ResourceModel\\Record', ['getValue', 'setValue', 'getFields', 'getStructure'], [], '', false); $structure = $this->getMock('\\Migration\\Structure', ['getFields'], [], '', false); $structure->expects($this->any())->method('getFields')->willReturn([$fieldName => ['DATA_TYPE' => $dataType]]); $recordToHandle->expects($this->any())->method('getValue')->willReturn($value); $recordToHandle->expects($this->any())->method('setValue')->with($fieldName, $newValue); $recordToHandle->expects($this->any())->method('getFields')->will($this->returnValue([$fieldName])); $recordToHandle->expects($this->any())->method('getStructure')->will($this->returnValue($structure)); $oppositeRecord = $this->getMockBuilder('Migration\\ResourceModel\\Record')->disableOriginalConstructor()->getMock(); $handler = new Timezone($offset); $handler->setField($fieldName); $handler->handle($recordToHandle, $oppositeRecord); }