Download the PHP package dama/doctrine-test-bundle without Composer

On this page you can find all versions of the php package dama/doctrine-test-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package doctrine-test-bundle

PHP Version Stable release

What does it do? :blush:

This bundle provides features that help you run your Symfony-framework-based App's testsuite more efficiently with isolated tests.

It provides a StaticDriver that will wrap your originally configured Driver class (like DBAL\Driver\PDOMysql\Driver) and keeps a database connection statically in the current php process.

With the help of a PHPUnit extension class it will begin a transaction before every testcase and roll it back again after the test finished for all configured DBAL connections. This results in a performance boost as there is no need to rebuild the schema, import a backup SQL dump or re-insert fixtures before every testcase. As long as you avoid issuing DDL queries that might result in implicit transaction commits (Like ALTER TABLE, DROP TABLE etc; see https://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis) your tests will be isolated and all see the same database state.

It also includes a Psr6StaticArrayCache that will be automatically configured as meta data & query cache for all EntityManagers. This improved the speed and memory usage for my testsuites dramatically! This is especially beneficial if you have a lot of tests that boot kernels (like Controller tests or ContainerAware tests) and use Doctrine entities.

How to install and use this Bundle?

  1. install via composer

  2. If you're not using Flex, enable the bundle by adding the class to bundles.php

  3. Starting from version 8 and only when using DBAL < 4 you need to make sure you have use_savepoints enabled on your doctrine DBAL configuration for all relevant connections:

Using the Bundle with PHPUnit

  1. Add the Extension to your PHPUnit XML config

    • PHPUnit 8 or 9:

    • PHPUnit 10+:
  2. Make sure you also have phpunit/phpunit available as a dev dependency (versions 8, 9 and 10 are supported with the built-in extension) to run your tests. Alternatively this bundle is also compatible with symfony/phpunit-bridge and its simple-phpunit script. (Note: you may need to make sure the phpunit-bridge requires the correct PHPUnit 8+ Version using the environment variable SYMFONY_PHPUNIT_VERSION).

  3. That's it! From now on whatever changes you do to the database within each single testcase (be it a WebTestCase or a KernelTestCase or any custom test) are automatically rolled back for you :blush:

Using the Bundle with Behat

Enable the extension in your Behat config (e.g. behat.yml)

That's it! From now on whatever changes you do to the database within each scenario are automatically rolled back for you.

Please note that this is only works if the tests are executed in the same process as Behat. This means it cannot work when using e.g. Selenium to call your application.

Configuration

The bundle exposes a configuration that looks like this by default:

Setting enable_static_connection: true means it will enable it for all configured doctrine dbal connections.

You can selectively only enable it for some connections if required:

Example

An example usage can be seen within the functional tests included in this bundle: https://github.com/dmaicher/doctrine-test-bundle/tree/master/tests

This bundle is also used on the official Symfony Demo testsuite: https://github.com/symfony/demo

Debugging

Sometimes it can be useful to be able to debug the database contents when a test failed. As normally all changes are rolled back automatically you can do this manually:

Troubleshooting

In case you are running (maybe without knowing it) queries during your tests that are implicitly committing any open transaction (see https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html for example) you might see an error like this:

Currently there is no way for this bundle to work with those queries as they simply cannot be rolled back after the test case finished.

See also https://github.com/dmaicher/doctrine-test-bundle/issues/58


All versions of doctrine-test-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 || ^8.0
ext-json Version *
doctrine/dbal Version ^3.3 || ^4.0
doctrine/doctrine-bundle Version ^2.2.2
psr/cache Version ^1.0 || ^2.0 || ^3.0
symfony/cache Version ^5.4 || ^6.3 || ^7.0
symfony/framework-bundle Version ^5.4 || ^6.3 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dama/doctrine-test-bundle contains the following files

Loading the files please wait ....