Skip to content

Instantly share code, notes, and snippets.

@0xMatt
Last active January 23, 2016 01:01
Show Gist options
  • Save 0xMatt/19b9432a86c5737a5cd9 to your computer and use it in GitHub Desktop.
Save 0xMatt/19b9432a86c5737a5cd9 to your computer and use it in GitHub Desktop.
doctrine:
dbal:
driver: pdo_sqlite
memory: true
<?php
class ImplementationTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->setUpDb();
}
public function testCreateReturnsNewUserWithValidParams()
{
$client = static::createClient();
// GET /foo - queries table from database for a list
$crawler = $client->request('GET', '/foo');
}
}
<?php
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\DependencyInjection\Container;
class TestCase extends WebTestCase
{
/**
* @var Container
*/
protected $container;
/**
* @var Application
*/
protected $console;
public function setUp()
{
static::bootKernel();
$this->container = static::$kernel->getContainer();
$this->console = new Application(static::$kernel);
$this->console->setAutoExit(false);
}
protected function runCommand($command)
{
$command = sprintf('%s --quiet', $command);
$this->console->run(
new StringInput($command)
);
}
protected function setUpDb()
{
$this->runCommand('doctrine:database:create --env=test');
$this->runCommand('doctrine:schema:update --env=test --force');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment