Craft\ImportServiceTest::testRowShouldCatchExceptions PHP Method

testRowShouldCatchExceptions() public method

    public function testRowShouldCatchExceptions()
    {
        $row = 1;
        $historyId = 2;
        $settings = array('map' => array('field1', 'field2'), 'type' => 'TypeExists', 'unique' => false, 'history' => $historyId);
        $mockException = $this->getMock('Craft\\Exception');
        $data = array('settings1' => array(), 'settings2' => array());
        $fields = array_combine($settings['map'], $data);
        $mockEntry = $this->getMockEntry();
        $mockEntry->expects($this->exactly(1))->method('setContentFromPost')->with($fields);
        $mockImportEntryService = $this->setMockImportEntryService($settings, $mockEntry, $fields);
        $mockImportEntryService->expects($this->exactly(1))->method('save')->willThrowException($mockException);
        $this->setMockImportHistoryService($historyId, $row, $this->isType('array'));
        $mockPluginsService = $this->getMock('Craft\\PluginsService');
        $mockPluginsService->expects($this->any())->method('call')->willReturnCallback(function ($method) use($mockException) {
            if ($method == 'registerImportService') {
                return;
            } else {
                throw $mockException;
            }
        });
        $this->setComponent(craft(), 'plugins', $mockPluginsService);
        $service = new ImportService();
        $service->row($row, $data, $settings);
    }