Created
November 29, 2011 23:07
-
-
Save jonotron/1407065 to your computer and use it in GitHub Desktop.
Functional test ACLs in Symfony
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
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 |
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 | |
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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.