enlitepro/enlite-test

Helpers for testing

dev-master 2013-09-03 13:01 UTC

This package is not auto-updated.

Last update: 2024-04-22 13:01:09 UTC


README

Modify TestConfig.php.dist and change glob path options to:

'config_glob_paths' => array(
    'config/autoload/{,*.}{global,local}.php',
    __DIR__ . "/global.php"
)

Create file glob.php near id test directory with options like this

<?php

return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver',
                'params' => array(
                    'memory' => true
                ),
            )
        ),
    ),
);

Now in your test you can use real database

<?php

class SomeTest extends \PHPUnit_Framework_TestCase
{
    use \EnliteTest\DatabaseFixtureTrait;

    public function testSave()
    {
        $entity = new Some();
        $entity->setTitle('hello');

        $em = $this->getEntityManager();
        $em->persist($entity);
        $em->flush();

        $this->assertSame($entity, $em->getRepository('Some')->find($entity->getId()));
    }

}