/** * @covers ::row * @covers ::getService */ public function testRowUniqueReplaceOrDeleteShouldFindExistingElement() { $row = 1; $historyId = 2; $settings = array('user' => 1, 'map' => array('field1' => 'field1', 'field2' => 'field2'), 'type' => 'TypeExists', 'unique' => array('field1' => 1, 'field2' => 0), 'history' => $historyId); $data = array('settings1' => 'value1', 'settings2' => 'value2'); $fields = array_combine($settings['map'], $data); $mockEntry = $this->getMockEntry(); $mockCriteria = $this->getMockCriteria(); $mockCriteria->expects($this->exactly(1))->method('count')->willReturn(1); $mockCriteria->expects($this->exactly(1))->method('first')->willReturn($mockEntry); $mockImportEntryService = $this->setMockImportEntryService($settings, $mockEntry, $fields, true); $mockImportEntryService->expects($this->exactly(1))->method('setCriteria')->with($settings)->willReturn($mockCriteria); $this->setMockImportHistoryService($historyId, $row, $this->isType('array')); $mockUser = $this->getMockUser(); $mockUser->expects($this->exactly(2))->method('can')->willReturnMap(array(array('delete', false), array('append', true))); $this->setMockUsersService($mockUser); $service = new ImportService(); $service->row($row, $data, $settings); }