2017 © Pedro Peláez
 

library laravel-app-spawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

image

web-chefs/laravel-app-spawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  • Monday, July 30, 2018
  • by web-chefs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 169 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

LaraAppSpawn

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

Laravel Custom Application Spawner is primarily used for creating a Application instance in a unit testing environment, allowing you to interact with Laravel in your tests., (*2)

By default it will use a SQLite in memory database, allowing you to run migrations and use a fully functional database during your tests., (*3)

It is up to you to migration and seed this test database., (*4)

Install

Via Composer, (*5)

``` bash $ composer require web-chefs/laravel-app-spawn --dev, (*6)


## Basic usage example ```php use Illuminate\Foundation\Testing\TestCase; use WebChefs\LaraAppSpawn\ApplicationResolver; class MyTest extends TestCase { /** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { // Root of my app, used as a fallback for location of /database when // database.path in config is null. $appRoutePath = __DIR__; // Resolve Application $resolver = ApplicationResolver::makeApp($appRoutePath); $this->app = $resolver->app(); // Run our database migrations if required $this->artisan('migrate:refresh', [ '--force' => 1 ]); return $this->app; } }

Example with custom configs

use Illuminate\Support\Arr;
use Illuminate\Foundation\Testing\TestCase;
use WebChefs\LaraAppSpawn\ApplicationResolver;

class MyTest extends TestCase
{
    /**
     * Creates the application.
     *
     * @return \Illuminate\Foundation\Application
     */
    public function createApplication()
    {
        // Root of my app, used as a fallback for location of /database when
        // database.path in config is null.
        $appRoutePath = __DIR__;

        // Build Resolver config
        $config = ApplicationResolver::defaultConfig();
        Arr::set($config, 'database.connection', $this->connectionName);
        Arr::set($config, 'queue.connection', $this->connectionName);

        // Resolve Application
        $resolver  = ApplicationResolver::makeApp($appRoutePath, $config);
        $this->app = $resolver->app();

        // Run our database migrations if required
        $this->artisan('migrate:refresh', [ '--force' => 1 ]);

        return $this->app;
    }

}

TravisCI

This was originally developed for WebChefs\QueueButler and for testing multiple version of Laravel using the same tests., (*7)

To see how that is possible see WebChefs\QueueButler .travis.yml., (*8)

Contributing

All code submissions will only be evaluated and accepted as pull-requests. If you have any questions or find any bugs please feel free to open an issue., (*9)

Credits

License

The MIT License (MIT). Please see License File for more information., (*10)

The Versions

30/07 2018

dev-master

9999999-dev https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging

07/06 2018

V1.4

1.4.0.0 https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging

05/06 2018

1.3

1.3.0.0 https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging

05/06 2018

1.2

1.2.0.0 https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging

05/06 2018

1.1

1.1.0.0 https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging

05/06 2018

1.0

1.0.0.0 https://github.com/web-chefs/LaraAppSpawn

Laravel custom application instance bootstrap creator. Used predominantly for doing Laravel specific testing.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Justin Fossey

database laravel test logging debugging