Skip to content

Instantly share code, notes, and snippets.

@ahmed-bhs
Last active November 13, 2018 13:29
Show Gist options
  • Save ahmed-bhs/0d2732b02a543cbfea77bcb943746a98 to your computer and use it in GitHub Desktop.
Save ahmed-bhs/0d2732b02a543cbfea77bcb943746a98 to your computer and use it in GitHub Desktop.
Unit test bootstrap file
<?php
declare(strict_types=1);
if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
throw new \LogicException('Run "composer install --dev" to create autoloader.');
}
require_once $autoloadFile;
$kernel = new \App\Kernel('test', true);
$kernel->boot();
$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
$application->setAutoExit(false);
$application->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'doctrine:database:drop',
'--force' => '1',
]));
$application->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'doctrine:database:create',
]));
$application->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'doctrine:schema:create',
]));
$application->run(new \Symfony\Component\Console\Input\ArrayInput([
'command' => 'doctrine:fixtures:load',
'--no-interaction' => '1',
]));
$kernel->shutdown();
sqlite:///:memory:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment