Skip to content

Instantly share code, notes, and snippets.

@jonotron
Created November 29, 2011 23:07
Show Gist options
  • Select an option

  • Save jonotron/1407065 to your computer and use it in GitHub Desktop.

Select an option

Save jonotron/1407065 to your computer and use it in GitHub Desktop.
Functional test ACLs in Symfony
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite # or %database_driver%
path: %kernel.cache_dir%/test.db
acl:
driver: pdo_sqlite # or %database_driver%
path: %kernel.cache_dir%/test.acl.db
security:
acl:
connection: acl
<?php
namespace AcmeBundle\Tests\Controller;
use Liip\LiipFunctionalTestBundle\Test\WebTestCase;
class MyControllerTest extends WebTestCase {
public function testSomeAclStuff() {
$this->runCommand('doctrine:database:drop', array('connection' => 'acl', 'force' => true));
$this->runCommand('init:acl');
$this->loadFixtures(array('Acme\Bundle\DataFixtures\MyFixture'));
// .... do your tests
}
}
@jonotron
Copy link
Copy Markdown
Author

If you normally keep your ACLs in the same database as your entities, you may encounter the following error when running your LiipFunctionalTests with init:acl and loadFixtures running in the same test: General error: 17 database schema has changed

To get around this, you can force ACL to use a separate database connection/location.

This will NOT destroy your ACL data with each test however... so you'd have to write a quick function to drop the ACL database in that instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment