2017 © Pedro Peláez
 

library doctrine-database-backup

Doctrine Database Backup

image

lucaszz/doctrine-database-backup

Doctrine Database Backup

  • Monday, October 24, 2016
  • by lzakrzewski
  • Repository
  • 0 Watchers
  • 17 Stars
  • 1,046 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

DoctrineDatabaseBackup

Build Status Latest Stable Version Total Downloads Coverage Status, (*1)

DoctrineDatabaseBackup is simple library for speed up tests in your app. It could be used for PHPUnit tests or Behat tests running from command line. My target was to avoid wasting time for dropping/creating or purging database for each test, so I optimized it., (*2)

This library puts contents of database to memory and share it between every tests., (*3)

Notice: I don't recommend to use this library with large fixtures because it can cause huge memory usage. I prefer to run tests with minimal database setup because it is more readable for me and it have better performance., (*4)

Requirements

  "require": {
    "php": ">=5.4",
    "doctrine/orm": "~2.3",
    "symfony/process": "~2.3"
  },

Features

  • It supports SqlitePlatform and MySqlPlatform,
  • It can create database backup per PHP process,
  • It can purge database in fast way,
  • It can restore database from backup before every test,
  • It can restore clear database before every test.

Installation

Require the library with composer:, (*5)

composer require lzakrzewski/doctrine-database-backup "~1.2"

Basic usage (PHPUnit example)

/** {@inheritdoc} */
protected function setUp()
{
    parent::setUp();

    $this->entityManager = $this->createEntityManager();

    $backup = new DoctrineDatabaseBackup($this->entityManager);
    $backup->restore();
}

This database setup prepares clear database before every test. Full working example., (*6)

Advanced usage (PHPUnit example)

/** {@inheritdoc} */
protected function setUp()
{
    parent::setUp();

    $this->entityManager = $this->createEntityManager();
    $backup = new DoctrineDatabaseBackup($this->entityManager);

    $backup->restore(function (EntityManager $entityManager) {
        //your fixtures
        $entityManager->persist(new TestProduct('Iron', 99));
        $entityManager->flush();
    });
}

This database setup database with your fixtures before every test. Full working example., (*7)

Notice: that before first test of PHP process database should be created., (*8)

Behat example

/** @BeforeScenario*/
public function restoreDatabase()
{
    // "getEntityManager" is your own getter for EntityManager
    $backup = new DoctrineDatabaseBackup($this->getEntityManager());
    $backup->restore();
}

The Versions

24/10 2016

dev-master

9999999-dev

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

24/10 2016

1.2.3

1.2.3.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

15/05 2016

1.2.2

1.2.2.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

10/05 2016

1.2.1

1.2.1.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

21/02 2016

1.2.0

1.2.0.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

07/02 2016

1.1.1

1.1.1.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar lzakrzewski

10/01 2016

1.1.0

1.1.0.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

05/10 2015

1.0.2

1.0.2.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

05/10 2015

1.0.0

1.0.0.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111

05/10 2015

1.0.1

1.0.1.0

Doctrine Database Backup

  Sources   Download

MIT

The Requires

 

The Development Requires

by lucaszz111