Created
August 9, 2012 09:24
-
-
Save binabik/3302634 to your computer and use it in GitHub Desktop.
bootstrap phpunit tests
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 | |
use Symfony\Bundle\SecurityBundle\Command\InitAclCommand; | |
use Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand; | |
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand; | |
require_once __DIR__.'/bootstrap.php.cache'; | |
require_once __DIR__.'/AppKernel.php'; | |
use Symfony\Bundle\FrameworkBundle\Console\Application; | |
use Symfony\Component\Console\Output\ConsoleOutput; | |
use Symfony\Component\Console\Input\ArrayInput; | |
$kernel = new AppKernel('test', true); // create a "test" kernel | |
$kernel->boot(); | |
$kernel->loadClassCache(); | |
$application = new Application($kernel); | |
// add the database:drop command to the application and run it | |
$command = new DropDatabaseDoctrineCommand(); | |
$application->add($command); | |
$input = new ArrayInput(array( | |
'command' => 'doctrine:database:drop', | |
'--force' => true, | |
)); | |
$command->run($input, new ConsoleOutput()); | |
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection(); | |
if ($connection->isConnected()) { | |
$connection->close(); | |
} | |
// add the database:create command to the application and run it | |
$command = new CreateDatabaseDoctrineCommand(); | |
$application->add($command); | |
$input = new ArrayInput(array( | |
'command' => 'doctrine:database:create', | |
)); | |
$command->run($input, new ConsoleOutput()); | |
// let Doctrine create the database schema (i.e. the tables) | |
$command = new CreateSchemaDoctrineCommand(); | |
$application->add($command); | |
$input = new ArrayInput(array( | |
'command' => 'doctrine:schema:create', | |
)); | |
$command->run($input, new ConsoleOutput()); | |
// populate test data from the fixtures | |
$command = new LoadDataFixturesDoctrineCommand(); | |
$application->add($command); | |
$input = new ArrayInput(array( | |
'command' => 'doctrine:fixtures:load' | |
)); | |
$command->run($input, new ConsoleOutput()); | |
// bootstrap acls | |
$command = new InitAclCommand(); | |
$application->add($command); | |
$input = new ArrayInput(array( | |
'command' => 'acl:init' | |
)); | |
$command->run($input, new ConsoleOutput()); | |
$connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection(); | |
if ($connection->isConnected()) { | |
$connection->close(); | |
} |
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> | |
<exclude>../vendor/doctrine/*</exclude> | |
</testsuite> | |
</testsuites> | |
<php> | |
<ini name="memory_limit" value="2047M" /> | |
</php> | |
<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