public static function setUpBeforeClass() { @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml'); @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php'); @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php'); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new GenerateRestControllerCommand())); $kernel->boot(); $command = $app->find('generate:rest:controller'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false)); $kernel->shutdown(); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new GenerateRestControllerCommand())); $kernel->boot(); $command = $app->find('generate:rest:controller'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false)); $kernel->shutdown(); @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php'); }
public function testRun() { $app = new Application(self::$kernel); $app->addCommands([new LoadFixturesCommand()]); $command = $app->find('amstaffix:fixtures:load'); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'dir-with-fixtures' => $this->dirWithFixtures], ['interactive' => false]); $this->assertEquals(4, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Article')); $this->assertEquals(3, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Author')); $this->assertEquals(8, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Book')); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new DropDatabaseDoctrineCommand())); $kernel->boot(); $command = $app->find('doctrine:database:drop'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--force' => true)); $kernel->shutdown(); }
public static function tearDownAfterClass() { parent::tearDownAfterClass(); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new DropSchemaDoctrineODMCommand())); $kernel->boot(); $command = $app->find('doctrine:mongodb:schema:drop'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName())); $kernel->shutdown(); }
public function testRun() { $app = new Application(self::$kernel); $app->addCommands([new GenerateFixturesFromProductionDBCommand()]); $command = $app->find('amstaffix:fixtures:generate-from-db'); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'target-dir' => $this->targetDir], ['interactive' => false]); $this->assertTrue(file_exists($this->fullDirPath)); $this->assertTrue(is_dir($this->fullDirPath)); $finder = (new Finder())->files()->name('*.js')->in($this->fullDirPath); foreach ($finder as $file) { /** @var SplFileInfo $file */ $this->assertNotEmpty(file_get_contents($file->getPathname())); } }
public function testSimple() { $dir = __DIR__ . '/../data/saved_extjs_models'; $app = new Application(self::$kernel); $app->addCommands([new SaveGeneratedExtJSModelsCommand()]); $command = $app->find('amstaffix:extjs-models:save'); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'target-dir' => $dir], ['interactive' => false]); $this->assertTrue(file_exists($dir)); $this->assertTrue(is_dir($dir)); $finder = (new Finder())->files()->name('*.js')->in($dir); foreach ($finder as $file) { /** @var SplFileInfo $file */ $this->assertNotEmpty(file_get_contents($file->getPathname())); } }
private static function initializeEnvironment() { // Boot the AppKernel in the test environment and with the debug. self::$kernel = new AppKernel('test', true); self::$kernel->boot(); // Create the application for command execution $helperSet = new HelperSet(); self::$application = new Application(self::$kernel); self::$application->setHelperSet($helperSet); self::$application->addCommands(self::enhance($helperSet, array(new RunSqlCommand(), new ImportCommand(), new ReservedWordsCommand(), new CreateDatabaseDoctrineCommand(), new DropDatabaseDoctrineCommand()))); self::$application->setAutoExit(false); // Store the container and the DB connection in test case properties self::$container = self::$kernel->getContainer(); self::$conn = self::$container->get('database_connection'); self::$transaction = self::$container->get('cantiga.transaction'); self::$eventDispatcher = new EventDispatcher(); $helperSet->set(new ConnectionHelper(self::$conn), 'db'); if (SharedResources::$dbInitializer !== null) { self::$dbInitializer = SharedResources::$dbInitializer; self::$dbReused = true; } else { SharedResources::$dbInitializer = self::$dbInitializer = new DBInitializer(self::$application, self::$container->getParameter('db_files')); } }