This repository has been archived by the owner on Aug 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Testbench\TDoctrine
Martin Zlámal edited this page Nov 5, 2016
·
5 revisions
Testbench is taking care of database creation and deletion. It can also load SQLs. Now it's up to you. Get entity manager and do whatever you want to do:
use \Testbench\TDoctrine;
public function testDatabase()
{
$em = $this->getEntityManager();
//Tester\Assert::...
}
Pretty easy, right?
Database tests can be very expensive and long running. You can mark them as slow:
use \Testbench\TCompiledContainer;
use \Testbench\TDoctrine;
public function testDatabaseSqls()
{
$this->changeRunLevel(\Testbench::SLOW); //or $this->markTestAsSlow();
//expensive test
}
It will skip this test if you run it with low runlevel (0 is default). You have to set RUNLEVEL
environment variable to run this test: $ RUNLEVEL=10 vendor/bin/run-tests ...
There are also Doctrine migrations available. To enable them you have to use Zenify\DoctrineMigrations
extension and enable migrations in configuration. Basic configuration may look like this:
doctrine:
driver: pdo_mysql
user: root
password: '...'
dbname: testbench_empty
extensions:
migrations: Zenify\DoctrineMigrations\DI\MigrationsExtension
- Symnedi\EventDispatcher\DI\EventDispatcherExtension #migrations
migrations:
directory: %appDir%/../Migrations
namespace: Testbench\Migrations
testbench:
url: http://test.bench/
migrations: yes
shareDatabase: no # should created test database persist?
dbprefix: _testbench_
sqls:
- %testsDir%/_helpers/sqls/mysql_1.sql
- %testsDir%/_helpers/sqls/mysql_2.sql