ApplicationTrait

trait ApplicationTrait (View source)

Properties

protected Application $app The Illuminate application instance.
protected int $code The last code returned by Artisan CLI.

Methods

void refreshApplication()

Refresh the application instance.

object instance(string $abstract, object $instance)

Register an instance of an object in the container.

$this expectsEvents(array|mixed $events)

Specify a list of events that should be fired for the given operation.

$this withoutEvents()

Mock the event dispatcher so all events are silenced.

$this expectsJobs(array|mixed $jobs)

Specify a list of jobs that should be dispatched for the given operation.

$this withSession(array $data)

Set the session to the given array.

void session(array $data)

Set the session to the given array.

void startSession()

Start the session for the application.

void flushSession()

Flush all of the current session data.

$this withoutMiddleware()

Disable middleware for the test.

$this actingAs(Authenticatable $user, string|null $driver = null)

Set the currently logged in user for the application.

void be(Authenticatable $user, string|null $driver = null)

Set the currently logged in user for the application.

$this seeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition exists in the database.

$this missingFromDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

$this dontSeeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

$this notSeeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

void seed(string $class = 'DatabaseSeeder')

Seed a given database connection.

int artisan(string $command, array $parameters = [])

Call artisan command and return code.

Details

protected void refreshApplication()

Refresh the application instance.

Return Value

void

protected object instance(string $abstract, object $instance)

Register an instance of an object in the container.

Parameters

string $abstract
object $instance

Return Value

object

$this expectsEvents(array|mixed $events)

Specify a list of events that should be fired for the given operation.

These events will be mocked, so that handlers will not actually be executed.

Parameters

array|mixed $events

Return Value

$this

protected $this withoutEvents()

Mock the event dispatcher so all events are silenced.

Return Value

$this

protected $this expectsJobs(array|mixed $jobs)

Specify a list of jobs that should be dispatched for the given operation.

These jobs will be mocked, so that handlers will not actually be executed.

Parameters

array|mixed $jobs

Return Value

$this

$this withSession(array $data)

Set the session to the given array.

Parameters

array $data

Return Value

$this

void session(array $data)

Set the session to the given array.

Parameters

array $data

Return Value

void

protected void startSession()

Start the session for the application.

Return Value

void

void flushSession()

Flush all of the current session data.

Return Value

void

$this withoutMiddleware()

Disable middleware for the test.

Return Value

$this

$this actingAs(Authenticatable $user, string|null $driver = null)

Set the currently logged in user for the application.

Parameters

Authenticatable $user
string|null $driver

Return Value

$this

void be(Authenticatable $user, string|null $driver = null)

Set the currently logged in user for the application.

Parameters

Authenticatable $user
string|null $driver

Return Value

void

protected $this seeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition exists in the database.

Parameters

string $table
array $data
string $connection

Return Value

$this

protected $this missingFromDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

Parameters

string $table
array $data
string $connection

Return Value

$this

protected $this dontSeeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

Parameters

string $table
array $data
string $connection

Return Value

$this

protected $this notSeeInDatabase(string $table, array $data, string $connection = null)

Assert that a given where condition does not exist in the database.

Parameters

string $table
array $data
string $connection

Return Value

$this

void seed(string $class = 'DatabaseSeeder')

Seed a given database connection.

Parameters

string $class

Return Value

void

int artisan(string $command, array $parameters = [])

Call artisan command and return code.

Parameters

string $command
array $parameters

Return Value

int

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.3/Illuminate/Foundation/Testing/ApplicationTrait.html