2017 © Pedro Peláez
 

library doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

image

matthiasnoback/doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

  • Wednesday, October 4, 2017
  • by matthiasnoback
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5,052 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 11 % Grown

The README.md

Doctrine ORM service provider for unit tests

Build Status, (*1)

This library contains a service provider to be used with a service container for PHPUnit tests., (*2)

Usage

Use the trait Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithEntityManager in your test class. You then need to implement the getEntityDirectories() which should return an array of the directories containing the entities that should be loaded., (*3)

For each test method a connection to an SQLite database will be available. Also the schema for the given entities will be created automatically., (*4)

<?php

use PHPUnit\Framework\TestCase;
use Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithEntityManager;

class StorageTest extends TestCase 
{
    use TestCaseWithEntityManager;

    protected function getEntityDirectories(): array
    {
        return array(
            __DIR__ . '/Entity'
        );
    }

    /**
     * @test
     */
    public function it_persists_an_entity()
    {
        $user = new User();
        $user->setName('Matthias');

        $this->getEntityManager()->persist($user);
        $this->getEntityManager()->flush();
    }
}

Of course, you would usually inject the entity manager into some object which is the subject-under-test., (*5)

To register Doctrine event listeners/subscribers, get the EventManager instance by calling $this->getEventManager(). To get the database Connection object, call $this->getConnection()., (*6)

Read more

The Versions

04/10 2017

dev-master

9999999-dev http://github.com/matthiasnoback/doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit service provider doctrine orm

04/10 2017
20/01 2015

v2.0.0

2.0.0.0 http://github.com/matthiasnoback/doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit service provider doctrine orm

16/12 2013

1.0.x-dev

1.0.9999999.9999999-dev http://github.com/matthiasnoback/doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit service provider doctrine orm

16/12 2013

v1.0.0

1.0.0.0 http://github.com/matthiasnoback/doctrine-orm-test-service-provider

Service provider for tests in need of a Doctrine entity manager

  Sources   Download

MIT

The Requires

 

The Development Requires

phpunit service provider doctrine orm