/**
  * @test
  */
 public function xmlImportWithMultipleValuesTest()
 {
     $this->extractorService->setSource(__DIR__ . '/../Fixtures/RemoteData/custom.xml');
     $this->extractorService->setMapping(array('items' => 'item', 'item' => array('title' => 'title', 'link' => 'link', 'datetime' => array('selector' => 'pubDate', 'strtotime' => 1), 'related_links' => array('selector' => 'related_link', 'multiple' => array('uri' => array('attr' => 'href'), 'title' => 'title')), 'image' => array('selector' => 'enclosure', 'multiple' => 1, 'attr' => 'url'))));
     $items = $this->extractorService->getItems();
     $this->assertCount(10, $items);
     $this->assertEquals('Middelburg verwijdert verkeerd geparkeerde fietsen op station', $items[0]->extractValue('title'));
     $this->assertEquals('http://www.nu.nl/walcheren/4048130/middelburg-verwijdert-verkeerd-geparkeerde-fietsen-station-.html', $items[0]->extractValue('link'));
     $this->assertEquals(1431452309, $items[0]->extractValue('datetime'));
     $images = $items[0]->extractValue('image');
     $this->assertCount(2, $images);
     $this->assertEquals('http://media.nu.nl/m/m1oxhrpa8daz_sqr256.jpg/middelburg-verwijdert-verkeerd-geparkeerde-fietsen-station-.jpg', $images[0]);
     $relatedLinks = $items[0]->extractValue('related_links');
     $this->assertCount(2, $relatedLinks);
     $this->assertEquals('http://www.nu.nl/walcheren/4048130/middelburg-verwijdert-verkeerd-geparkeerde-fietsen-station-.html', $relatedLinks[0]['uri']);
     $this->assertEquals('Extra link 1', $relatedLinks[0]['title']);
 }
 /**
  * Test import source by counting found items and displaying data of first item
  *
  * @param ImportSource $importSource
  */
 public function testSourceCommand(ImportSource $importSource)
 {
     $this->outputLine('Fetch: ' . $importSource->getUrl());
     $this->outputDashedLine();
     $this->extractorService->setSource($importSource->getUrl());
     $this->extractorService->setMapping($importSource->getMapping());
     $items = $this->extractorService->getItems();
     $this->outputLine('Found ' . count($items) . ' items');
     $this->outputDashedLine();
     if (count($items)) {
         $this->outputLine('GUID: ' . $items[0]->getGuid());
         $this->outputDashedLine();
         $this->outputLine(print_r($items[0]->toArray(), 1));
     }
 }
 /**
  * Import item
  *
  * @param ImportSource $importSource
  * @param string $guid
  * @return string
  * @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
  */
 public function importAction(ImportSource $importSource, $guid)
 {
     $this->extractorService->setSource($importSource->getUrl());
     $this->extractorService->setMapping($importSource->getMapping());
     $extractedItems = $this->extractorService->getItems();
     foreach ($extractedItems as $item) {
         if ($item->getGuid() === $guid) {
             $this->importService->importItem($importSource, $item);
             $itemUid = $this->importService->alreadyImported($importSource->getPid(), $guid);
             $this->uriBuilder->reset()->setCreateAbsoluteUri(TRUE);
             if (\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
                 $this->uriBuilder->setAbsoluteUriScheme('https');
             }
             $returnUrl = $this->uriBuilder->uriFor('show', array('importSource' => $importSource), $this->request->getControllerName());
             $this->redirectToUri('alt_doc.php?returnUrl=' . rawurlencode($returnUrl) . '&edit[tx_news_domain_model_news][' . $itemUid . ']=edit&disHelp=1');
         }
     }
     $this->addFlashMessage('requested-item-not-found', '', AbstractMessage::ERROR);
     $this->redirect('show', NULL, NULL, array('importSource' => $importSource));
 }