/** * import a single file into a collection * * @param SplFileInfo $file file * @param InputInterface $input User input on console * @param OutputInterface $output Output of the command * * @return void */ private function importResource(\SplFileInfo $file, InputInterface $input, OutputInterface $output) { $doc = $this->frontMatter->parse($file->getContents()); $origDoc = $this->serializer->unserialize($doc->getContent()); if (is_null($origDoc)) { $output->writeln("<error>Could not deserialize file <{$file}></error>"); } else { $collectionName = $doc->getData()['collection']; $this->getClient($input)->selectCollection($this->databaseName, $collectionName)->save($origDoc); $output->writeln("<info>Imported <{$file}> to <{$collectionName}></info>"); } }
/** * see if mongoid/mongodate can be properly unserialized again.. * * @return void */ public function testMongoHandling() { $origClass = new \stdClass(); $origClass->id = 'Class'; $origClass->mongoId = new \MongoId(); $origClass->mongoDate = new \MongoDate(); $serializer = new JsonSerializer(); $serialized = $serializer->serialize($origClass); $class = $serializer->unserialize($serialized); $this->assertEquals($origClass, $class); }