/**
  * Executes the current command.
  *
  * @param \Yosymfony\Spress\Core\IO\IOInterface $io        Input/output interface.
  * @param array                                 $arguments Arguments passed to the command.
  * @param array                                 $options   Options passed to the command.
  *
  * @return null|int null or 0 if everything went fine, or an error code.
  */
 public function executeCommand(IOInterface $io, array $arguments, array $options)
 {
     $header = false;
     $style = new SpressImportConsoleStyle($io);
     $file = $arguments['file'];
     $srcPath = __DIR__ . '/../../../../';
     $style->title('Importing from a CSV file');
     $providerCollection = new ProviderCollection(['csv' => new CsvProvider()]);
     $providerManager = new ProviderManager($providerCollection, $srcPath);
     if ($options['dry-run'] == true) {
         $providerManager->enableDryRun();
         $io->write('<info>Dry-run enabled</info>');
     }
     if ($options['not-header'] == true) {
         $header = true;
         $io->write('<info>CSV file without header</info>');
     }
     if ($options['not-replace-urls'] == true) {
         $providerManager->doNotReplaceUrls();
     }
     if (is_null($options['post-layout']) == false) {
         $providerManager->setPostLayout($options['post-layout']);
     }
     $io->write('<info>Starting...</info>');
     try {
         $itemResults = $providerManager->import('csv', ['file' => $file, 'not_header' => $header, 'delimiter_character' => $options['delimiter-character'], 'enclosure_character' => $options['enclosure-character'], 'terms_delimiter_character' => $options['terms-delimiter-character']]);
         $style->ResultItems($itemResults);
     } catch (Exception $e) {
         $style->error($e->getMessage());
     }
 }
 /**
  * Executes the current command.
  *
  * @param \Yosymfony\Spress\Core\IO\IOInterface $io        Input/output interface.
  * @param array                                 $arguments Arguments passed to the command.
  * @param array                                 $options   Options passed to the command.
  *
  * @return null|int null or 0 if everything went fine, or an error code.
  */
 public function executeCommand(IOInterface $io, array $arguments, array $options)
 {
     $style = new SpressImportConsoleStyle($io);
     $file = $arguments['file'];
     $srcPath = __DIR__ . '/../../../../';
     $style->title('Importing from a Wordpress WXR file');
     $providerCollection = new ProviderCollection(['wxr' => new WxrProvider()]);
     $assetsDir = $options['assets-dir'];
     $providerManager = new ProviderManager($providerCollection, $srcPath, $assetsDir);
     if ($options['dry-run'] == true) {
         $providerManager->enableDryRun();
         $io->write('<info>Dry-run enabled</info>');
     }
     if ($options['fetch-images'] == true) {
         $providerManager->enableFetchResources();
     }
     if ($options['not-replace-urls'] == true) {
         $providerManager->doNotReplaceUrls();
     }
     if (is_null($options['post-layout']) == false) {
         $providerManager->setPostLayout($options['post-layout']);
     }
     $io->write('<info>Starting...</info>');
     try {
         $itemResults = $providerManager->import('wxr', ['file' => $file]);
         $style->ResultItems($itemResults);
     } catch (Exception $e) {
         $style->error($e->getMessage());
     }
 }
    public function testNoPathInPagePermalink()
    {
        $providerCollection = new ProviderCollection(['array' => new ArrayProvider([['type' => 'page', 'permalink' => 'http://mysite.com/?page=1']])]);
        $providerManager = new ProviderManager($providerCollection, $this->srcPath);
        $providerManager->enableDryRun();
        $itemResults = $providerManager->import('array', []);
        $itemResult = $itemResults[0];
        $content = <<<EOC
---
no_html_extension: true

---

EOC;
        $this->assertEquals($content, $itemResult->getContent());
        $this->assertEquals('content/index.html', $itemResult->getRelativePath());
        $this->assertEquals('', $itemResult->getPermalink());
    }