MigrationsTrait

Trait MigrationsTrait Migrations trait for auto execute migrations during test running.

Additionally running seed command. Seed command based on sonrac/symfony-seed-command package.

Init property $seed in your test class for seed execute. Property is list seed classes.

example

seeds located by namespace Tests\Seeds and ending with TableSeeder Seeds List are:

  • Tests\Seeds\UsersTableSeeder
  • Tests\Seeds\RolesTableSeeder

In test adding property $seeds: class ExampleTest extends TestCase { use BootTraits, MigrationsTrait; protected function setUp() { parent::setUp(); $this->setSeedsNamespace('Tests\Seeds') $this->setSeedClassEnding('TableSeeder')->_boot(); } protected static $seeds = ['users', 'roles'] }

All seeds running in inclusion order.

package

Default

Methods

Run migrations.

bootMigrationsTrait() 
Throws
\Exception

Get console command directory.

getBinDir() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get console command name. By default is `console`.

getConsoleCommand() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get migration command name. By default is `migrations:migrate --no-interaction`.

getMigrationCommand() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Fetch migrations list for rollback.

getMigrationsList() : boolean|array
author

Donii Sergii doniysa@gmail.com

Response

boolean|array

Get migration table. By default is `migration_versions`.

getMigrationTable() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get php executor.

getPhpExecutor() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get command which will be running before. By default is `'export APP_ENV=testing'`.

getPreCommand() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get rollback migration command name. By default is `migrations:execute --down --no-interaction`.

getRollbackMigrationCommand() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get seed class repeat ending name (will be concatenated with origin name).

getSeedClassEnding() : null|string
author

Donii Sergii doniysa@gmail.com

Response

null|string

Get seed command. By default is `seed:run --class=` from package `sonrac/symfony-seed-command`.

getSeedCommand() : string
author

Donii Sergii doniysa@gmail.com

Response

string

Get seeds classes namespace.

getSeedNamespace() : null|string
author

Donii Sergii doniysa@gmail.com

Response

null|string

Get seeds.

getSeeds() : array
author

Donii Sergii doniysa@gmail.com

Response

array

Check flag continue on command execute failure status.

isContinueOnFailure() : boolean
author

Donii Sergii doniysa@gmail.com

Response

boolean

Rollback all migrations.

rollback() : null|false
author

Donii Sergii doniysa@gmail.com

Throws
\Exception

Response

null|false

Run command.

runCommand(string $command) 
Throws
\Exception

Arguments

$command

string

Run migrations.

runMigration() 
author

Donii Sergii doniysa@gmail.com

Throws
\Exception

Run seed.

runSeed(string $seed) 
author

Donii Sergii doniysa@gmail.com

Throws
\Exception

Arguments

$seed

string

Run seeds.

runSeeds() 
author

Donii Sergii doniysa@gmail.com

Throws
\Exception

Set console command directory.

setBinDir(string $binDir) : $this
author

Donii Sergii doniysa@gmail.com

Arguments

$binDir

string

Response

$this

Set console command name. By default is `console`.

setConsoleCommand(string $consoleCommand) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$consoleCommand

string

Response

\sonrac\FCoverage\MigrationsTrait

Set flag continue on command execute failure status.

setContinueOnFailure(boolean $continueOnFailure) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$continueOnFailure

boolean

Response

\sonrac\FCoverage\MigrationsTrait

Set migration command name. By default is `migrations:migrate --no-interaction`.

setMigrationCommand(string $migrationCommand) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$migrationCommand

string

Response

\sonrac\FCoverage\MigrationsTrait

Set migration table. By default is `migration_versions`.

setMigrationTable(string $migrationTable) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$migrationTable

string

Response

\sonrac\FCoverage\MigrationsTrait

Set php executor.

setPhpExecutor(string $phpExecutor) : $this
author

Donii Sergii doniysa@gmail.com

Arguments

$phpExecutor

string

Response

$this

Set command which will be running before. By default is `'export APP_ENV=testing'`.

setPreCommand(string $preCommand) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$preCommand

string

Response

\sonrac\FCoverage\MigrationsTrait

Set rollback migration command name. By default is `migrations:execute --down --no-interaction`.

setRollbackMigrationCommand(string $rollbackMigrationCommand) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$rollbackMigrationCommand

string

Response

\sonrac\FCoverage\MigrationsTrait

Set seed class repeat ending name (will be concatenated with origin name).

setSeedClassEnding(null|string $seedClassEnding) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$seedClassEnding

null|string

Response

\sonrac\FCoverage\MigrationsTrait

Set seed command. By default is `seed:run --class=` from package `sonrac/symfony-seed-command`.

setSeedCommand(string $seedCommand) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$seedCommand

string

Response

\sonrac\FCoverage\MigrationsTrait

Set seed classes namespace.

setSeedNamespace(null|string $seedNamespace) : \sonrac\FCoverage\MigrationsTrait
author

Donii Sergii doniysa@gmail.com

Arguments

$seedNamespace

null|string

Response

\sonrac\FCoverage\MigrationsTrait

Properties

Path to console command dir.

binDir : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Php executor name.

phpExecutor : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Console command name.

consoleCommand : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Seed classes namespace.

seedNamespace : null|string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

null|string

Seed class ending name.

seedClassEnding : string|null
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string|null

Migration table name.

migrationTable : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Migration command name.

migrationCommand : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Rollback migration command name.

rollbackMigrationCommand : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

Command which will be running before. By default is `'export APP_ENV=testing'`.

preCommand : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string

If true will be continue on command execute failure status.

continueOnFailure : boolean
var
author

Donii Sergii doniysa@gmail.com

Type(s)

boolean

Seed command. By default is `seed:run --class=` from package `sonrac/symfony-seed-command`.

seedCommand : string
var
author

Donii Sergii doniysa@gmail.com

Type(s)

string