Ejemplo n.º 1
0
 public function run(ChefContext $context)
 {
     $result = $context->getResult();
     // Validate arguments.
     $format = $result->command->args['format'];
     $source = $result->command->args['source'];
     if (!$format or !$source) {
         // Warning for the old syntax.
         throw new PieCrustException("The syntax for this command has changed: specify the format and the source as arguments. See `chef import -h` for help.");
     }
     // Start importing!
     $importer = new PieCrustImporter($context->getApp(), $context->getLog());
     $importer->import($format, $source, $result->command->options);
 }
 public function testImportWordpress()
 {
     $fs = MockFileSystem::create()->withPagesDir()->withPostsDir();
     $app = new PieCrust(array('root' => $fs->getAppRoot()));
     $importer = new PieCrustImporter($app);
     $sampleXml = PIECRUST_UNITTESTS_TEST_DATA_DIR . 'import/wordpress.test-data.2011-01-17.xml';
     $importer->import('wordpress', $sampleXml, array());
     // Re-create the app to load from the new values.
     $app = new PieCrust(array('root' => $fs->getAppRoot()));
     // Check the content.
     $pcFs = FileSystem::create($app);
     $pageFiles = $pcFs->getPageFiles();
     $this->assertCount(11, $pageFiles);
     $postFiles = $pcFs->getPostFiles();
     $this->assertCount(22, $postFiles);
 }