Craft\ImportServiceTest::testRowUniqueReplaceOrDeleteShouldLogErrorWhenDeleteFails PHP 메소드

testRowUniqueReplaceOrDeleteShouldLogErrorWhenDeleteFails() 공개 메소드

    public function testRowUniqueReplaceOrDeleteShouldLogErrorWhenDeleteFails()
    {
        $row = 1;
        $historyId = 2;
        $settings = array('user' => 1, 'map' => array('field1' => 'field1', 'field2' => 'field2'), 'type' => 'TypeExists', 'unique' => array('field1' => 1, 'field2' => 0), 'history' => $historyId, 'behavior' => ImportModel::BehaviorDelete);
        $data = array('settings1' => 'value1', 'settings2' => 'value2');
        $fields = array_combine($settings['map'], $data);
        $mockEntry = $this->getMockEntry();
        $mockException = $this->getMock('Craft\\Exception');
        $mockCriteria = $this->getMockCriteria();
        $mockCriteria->expects($this->exactly(1))->method('count')->willReturn(1);
        $mockCriteria->expects($this->exactly(1))->method('find')->willReturn(array($mockEntry));
        $mockImportEntryService = $this->setMockImportEntryService($settings, $mockEntry, $fields);
        $mockImportEntryService->expects($this->exactly(1))->method('setCriteria')->with($settings)->willReturn($mockCriteria);
        $mockImportEntryService->expects($this->exactly(1))->method('delete')->willThrowException($mockException);
        $this->setMockImportHistoryService($historyId, $row, $this->isType('array'));
        $mockUser = $this->getMockUser();
        $mockUser->expects($this->exactly(1))->method('can')->willReturnMap(array(array('delete', true)));
        $this->setMockUsersService($mockUser);
        /** @var ImportService $service */
        $service = $this->getMock('Craft\\ImportService', array('onBeforeImportDelete'));
        $service->row($row, $data, $settings);
    }