Download the PHP package vierge-noire/cakephp-test-migrator without Composer

On this page you can find all versions of the php package vierge-noire/cakephp-test-migrator. 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 cakephp-test-migrator

cakephp-test-migrator

A tool to run migrations prior to running tests

The Migrator

For CakePHP 3.x

composer require --dev vierge-noire/cakephp-test-migrator "^1.0"

For CakePHP 4.x

composer require --dev vierge-noire/cakephp-test-migrator "^2.0"

For CakePHP 4.3+

The migrator was integrated into the migration plugin (see the doc). The present package will not be further maintained.

Introduction

CakePHP fixtures handle the test DB schema in a paralell manner to the default DB. On the one hand you will write migrations for your default DB. On the other hand you either hard coded describe the schema structure in your fixtures, or meme the default DB. The later is simpler, but it forces you to have two DBs. And in CI tools, you will have to run the migrations on your default DB, and the fixtures meme the default DB. So why not running migrations directly on the test DB?

With the CakePHP Test Migrator, the schema of both default and test DB are handled exactly in the same way. You do not necessarily need a default DB. Tables are not dropped between test suites, which speeds up your tests. And migrations are part of the whole testing process: they get indirectly tested.

Setting

The package proposes a tool to run your migrations once prior to the tests. In order to do so, you may place the following in your tests/bootstrap.php:

This command will ensure that your migrations are well run and keeps the test DB(s) up to date. Since tables are truncated but never dropped by the present package's fixture manager, migrations will be run strictly when needed, namely only after a new migration was created by the developer.

The Migratorapproach presents the following advantages:

You may pass true as the second argument for a verbose output on the console.

Options

name type default description
verbose bool false Print info about migrations done
truncate bool true Truncate all tables after migrations are done. You can call truncate() manually

You can pass a boolean as options, it will be used as verbose

Multiple migrations settings

You can pass the various migrations directly in the Migrator instantiation:

You can also pass the various migrations directly in your Datasource configuration, under the key migrations:

You can set migrations simply to true if you which to use the default migration settings.

Migrations status

Information on a connection's migration status will be obtained as follows:

the method getConnectionsWithModifiedStatus returning a list of the connections with down migrations prior to running the migrations.

Data truncation

Use truncate option to truncate (or not) after migrations are done. This is useful if you need to do other tasks in the test suite bootstrap

What happens if I switch branches?

If you ever switched to a branch with nonexistent up migrations, you've moved to a branch in a past state. The Migrator will automatically drop the tables where needed, and re-run the migrations. Switching branches therefore does not require any intervention on your side.

What if I do not use migrations?

The Migrator::dump() will help you import any schema from one or several sql file. Run for example:

or with multiples files

or for a verbose output

The first argument is the name of the connection, the second the file(s) to dump, the third the verbosity (boolean).

This method will however drop the schema prior to recreating it, which presents a significant loss of performance in comparison to the migration-based solution.

Trouble shooting

It might be required, right after you installed or updated the plugin, to drop and recreate your test database. If the problem persists, feel free to open an issue.

Authors

Support

Contact us at [email protected] for professional assistance.

You like our work? ko-fi

License

The CakephpTestMigrator plugin is offered under an MIT license.

Copyright 2020 Juan Pablo Ramirez and Nicolas Masson

Licensed under The MIT License Redistributions of files must retain the above copyright notice.


All versions of cakephp-test-migrator with dependencies

PHP Build Version
Package Version
Requires cakephp/cakephp Version ^4.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 vierge-noire/cakephp-test-migrator contains the following files

Loading the files please wait ....