-
-
Save pschultz/4153054 to your computer and use it in GitHub Desktop.
symfony 2 test configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in /app/bootstrap.phpunit.php: | |
require_once __DIR__.'/bootstrap.php.cache'; | |
require_once __DIR__.'/AppKernel.php'; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\ArrayInput; | |
use Symfony\Component\Console\Output\ConsoleOutput; | |
use Symfony\Bundle\FrameworkBundle\Console\Application; | |
use Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand; | |
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand; | |
$environment = getenv('SF2_TEST_ENV') ?: 'test'; | |
$kernel = new AppKernel($environment, true); | |
$kernel->boot(); | |
$application = new Application($kernel); | |
$runCommand = function (Command $command, array $args) use ($application) { | |
$application->add($command); | |
$input = new ArrayInput($args); | |
$input->setInteractive(false); | |
$command->run($input, new ConsoleOutput()); | |
}; | |
$runCommand(new DropDatabaseDoctrineCommand, [ | |
'command' => 'doctrine:database:drop', | |
'--force' => true, | |
]); | |
$runCommand(new CreateDatabaseDoctrineCommand, [ | |
'command' => 'doctrine:database:create', | |
]); | |
$runCommand(new CreateSchemaDoctrineCommand, [ | |
'command' => 'doctrine:schema:create', | |
]); | |
try { | |
$runCommand(new LoadDataFixturesDoctrineCommand, [ | |
'command' => 'doctrine:fixtures:load', | |
'--env' => $environment | |
]); | |
} catch (InvalidArgumentException $ignored) { | |
// thrown when there are no fixtures to load | |
} | |
$runCommand(new CacheWarmupCommand, [ | |
'command' => 'cache:warmup', | |
'--env' => $environment | |
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
imports: | |
- { resource: config_dev.yml } | |
framework: | |
test: ~ | |
session: | |
storage_id: session.storage.filesystem | |
doctrine: | |
dbal: | |
default_connection: default | |
connections: | |
default: | |
driver: pdo_sqlite | |
path: %kernel.cache_dir%/test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html --> | |
<phpunit | |
backupGlobals = "false" | |
backupStaticAttributes = "false" | |
colors = "true" | |
convertErrorsToExceptions = "true" | |
convertNoticesToExceptions = "true" | |
convertWarningsToExceptions = "true" | |
processIsolation = "false" | |
stopOnFailure = "false" | |
syntaxCheck = "false" | |
bootstrap = "bootstrap.phpunit.php" > | |
<testsuites> | |
<testsuite name="Project Test Suite"> | |
<directory>../src/*/*Bundle/Tests</directory> | |
<directory>../src/*/Bundle/*Bundle/Tests</directory> | |
</testsuite> | |
</testsuites> | |
<filter> | |
<whitelist> | |
<directory>../src</directory> | |
<exclude> | |
<directory>../src/*/*Bundle/Resources</directory> | |
<directory>../src/*/*Bundle/Tests</directory> | |
<directory>../src/*/Bundle/*Bundle/Resources</directory> | |
<directory>../src/*/Bundle/*Bundle/Tests</directory> | |
</exclude> | |
</whitelist> | |
</filter> | |
</phpunit> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment