2017 © Pedro Peláez
 

package laravel-testing-helper-traits

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

image

betapeak/laravel-testing-helper-traits

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  • Tuesday, October 31, 2017
  • by ymslavov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

The included trait provides additional features on top of the existing DatabaseMigrations trait currently included with Laravel: - Using 'migrate:refresh' instead of the hardcoded 'migrate:fresh' by including a property on your test class protected $useRefreshMigrations = true;, (*1)

  • Using custom seeders which can be defined separately for each test protected $seederClass = 'AnotherDatabaseSeeder';

Installation

This package requires that you are using laravel/framework: 5.5.*. Provided this is fulfilled, you can install the helper traits like so:, (*2)

composer require betapeak/laravel-testing-helper-traits

Usage

You can use the included DatabaseMigrationsWithSeeding trait in place of the existing DatabaseMigrations trait included in Laravel. Like the default trait, it will migrate:fresh the database, but will also seed it with the default DatabaseSeeder class., (*3)

namespace Tests;
use BetaPeak\Testing\Traits\DatabaseMigrationsWithSeeding;

class SomeUnitTest extends TestCase
{
    use DatabaseMigrationsWithSeeding;


    /** @test */
    public function it_tests_something()
    {
        //Test something
    }

}

You can specify a different seeder class like so:, (*4)

namespace Tests;
use BetaPeak\Testing\Traits\DatabaseMigrationsWithSeeding;

class SomeUnitTest extends TestCase
{
    use DatabaseMigrationsWithSeeding;

    protected $seederClass = 'AnotherSeederClass';

    ...

}

Finally, if you don't want to use migrate:fresh, you can force the trait to use migrate:refresh like so:, (*5)

namespace Tests;
use BetaPeak\Testing\Traits\DatabaseMigrationsWithSeeding;

class SomeUnitTest extends TestCase
{
    use DatabaseMigrationsWithSeeding;

    protected $useRefreshMigrations = true;

    ...

}

More information on using database migrations in tests can be found on Laravel's homepage, (*6)

The Versions

31/10 2017

dev-master

9999999-dev

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  Sources   Download

MIT

The Requires

 

by Yasen Slavov

laravel testing traits

31/10 2017

1.0.1

1.0.1.0

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  Sources   Download

MIT

The Requires

 

by Yasen Slavov

laravel testing traits

31/10 2017

1.0

1.0.0.0

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  Sources   Download

MIT

The Requires

 

by Yasen Slavov

laravel testing traits

31/10 2017

0.1

0.1.0.0

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  Sources   Download

MIT

The Requires

 

by Yasen Slavov

laravel testing traits

31/10 2017

0.2

0.2.0.0

Adds traits similar to the DatabaseMigtaions trait, but with added seeding.

  Sources   Download

MIT

The Requires

 

by Yasen Slavov

laravel testing traits