/** * @param InputInterface $input * @param OutputInterface $output * * @return mixed * @throws \InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { if (!is_null($input->getOption('type'))) { $type = $input->getOption('type'); } else { $type = $this->getHelperSet()->get('dialog')->ask($output, 'Choose type in ' . implode(', ', $this->getContainer()->getParameter('open_orchestra_model.fixtures.command')) . ' (all) : ', 'all'); } $dm = $this->getContainer()->get('doctrine_mongodb')->getManager($input->getOption('dm')); $dirOrFile = $input->getOption('fixtures'); if ($dirOrFile) { $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile); } else { $paths = $this->getContainer()->getParameter('doctrine_mongodb.odm.fixtures_dirs'); $paths = is_array($paths) ? $paths : array($paths); foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) { $paths[] = $bundle->getPath() . '/DataFixtures/MongoDB'; } } $loader = new OrchestraContainerAwareLoader($this->getContainer(), $type); foreach ($paths as $path) { if (is_dir($path)) { $loader->loadFromDirectory($path); } } $fixtures = $loader->getFixtures(); if (!$fixtures) { throw new \InvalidArgumentException(sprintf('Could not find any fixtures of %s type to load in: %s', $type, "\n\n- " . implode("\n- ", $paths))); } $purger = new MongoDBPurger($dm); $executor = new MongoDBExecutor($dm, $purger); $executor->setLogger(function ($message) use($output) { $output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message)); }); $executor->execute($fixtures, $input->getOption('append')); }
/** * @param bool $transient * @param string $className * * @dataProvider provideTransientAndClassName */ public function testIsTransient($transient, $className) { $this->assertSame($transient, $this->loader->isTransient($className)); }