class Illuminate / Support / Testing / Fakes / BusFake

BusFake

Implements

Uses

Properties

public

$dispatcher QueueingDispatcher

The original Bus dispatcher implementation.

Default: null
protected

$jobsToFake array

The job types that should be intercepted instead of dispatched.

Default: []
protected

$jobsToDispatch array

The job types that should be dispatched instead of faked.

Default: []
protected

$batchRepository BatchRepository

The fake repository to track batched jobs.

Default: null
protected

$commands array

The commands that have been dispatched.

Default: []
protected

$commandsSync array

The commands that have been dispatched synchronously.

Default: []
protected

$commandsAfterResponse array

The commands that have been dispatched after the response has been sent.

Default: []
protected

$batches array

The batches that have been dispatched.

Default: []

Methods

public

__construct ( QueueingDispatcher $dispatcher , $jobsToFake , BatchRepository $batchRepository ) : void

Create a new bus fake instance.

Parameters

public

except ( $jobsToDispatch ) : $this

Specify the jobs that should be dispatched instead of faked.

Parameters

  • $jobsToDispatch array|string
public

assertDispatched ( $command , $callback ) : void

Assert if a job was dispatched based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|int|null
public

assertDispatchedTimes ( $command , $times ) : void

Assert if a job was pushed a number of times.

Parameters

public

assertNotDispatched ( $command , $callback ) : void

Determine if a job was dispatched based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|null
public

assertNothingDispatched ( ) : void

Assert that no jobs were dispatched.

public

assertDispatchedSync ( $command , $callback ) : void

Assert if a job was explicitly dispatched synchronously based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|int|null
public

assertDispatchedSyncTimes ( $command , $times ) : void

Assert if a job was pushed synchronously a number of times.

Parameters

public

assertNotDispatchedSync ( $command , $callback ) : void

Determine if a job was dispatched based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|null
public

assertDispatchedAfterResponse ( $command , $callback ) : void

Assert if a job was dispatched after the response was sent based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|int|null
public

assertDispatchedAfterResponseTimes ( $command , $times ) : void

Assert if a job was pushed after the response was sent a number of times.

Parameters

public

assertNotDispatchedAfterResponse ( $command , $callback ) : void

Determine if a job was dispatched based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|null
public

assertChained ( array $expectedChain ) : void

Assert if a chain of jobs was dispatched.

Parameters

  • $expectedChain array
protected

resetChainPropertiesToDefaults ( $job ) : mixed

Reset the chain properties to their default values on the job.

Parameters

  • $job mixed
public

assertDispatchedWithoutChain ( $command , $callback ) : void

Assert if a job was dispatched with an empty chain based on a truth-test callback.

Parameters

  • $command string|Closure
  • $callback callable|null
protected

assertDispatchedWithChainOfObjects ( $command , $expectedChain , $callback ) : void

Assert if a job was dispatched with chained jobs based on a truth-test callback.

Parameters

  • $command string
  • $expectedChain array
  • $callback callable|null
protected

assertDispatchedWithChainOfClasses ( $command , $expectedChain , $callback ) : void

Assert if a job was dispatched with chained jobs based on a truth-test callback.

Parameters

  • $command string
  • $expectedChain array
  • $callback callable|null
protected

isChainOfObjects ( $chain ) : bool

Determine if the given chain is entirely composed of objects.

Parameters

  • $chain array
public

assertBatched ( callable $callback ) : void

Assert if a batch was dispatched based on a truth-test callback.

Parameters

  • $callback callable
public

assertBatchCount ( $count ) : void

Assert the number of batches that have been dispatched.

Parameters

  • $count int
public

assertNothingBatched ( ) : void

Assert that no batched jobs were dispatched.

public

dispatched ( $command , $callback ) : Illuminate\...\Collection

Get all of the jobs matching a truth-test callback.

Parameters

  • $command string
  • $callback callable|null
public

dispatchedSync ( string $command , $callback ) : Illuminate\...\Collection

Get all of the jobs dispatched synchronously matching a truth-test callback.

Parameters

  • $command string
  • $callback callable|null
public

dispatchedAfterResponse ( string $command , $callback ) : Illuminate\...\Collection

Get all of the jobs dispatched after the response was sent matching a truth-test callback.

Parameters

  • $command string
  • $callback callable|null
public

batched ( callable $callback ) : Illuminate\...\Collection

Get all of the pending batches matching a truth-test callback.

Parameters

  • $callback callable
public

hasDispatched ( $command ) : bool

Determine if there are any stored commands for a given class.

Parameters

  • $command string
public

hasDispatchedSync ( $command ) : bool

Determine if there are any stored commands for a given class.

Parameters

  • $command string
public

hasDispatchedAfterResponse ( $command ) : bool

Determine if there are any stored commands for a given class.

Parameters

  • $command string
public

dispatch ( $command ) : mixed

Dispatch a command to its appropriate handler.

Parameters

  • $command mixed
public

dispatchSync ( $command , $handler ) : mixed

Dispatch a command to its appropriate handler in the current process.

Parameters

  • $command mixed
  • $handler mixed
public

dispatchNow ( $command , $handler ) : mixed

Dispatch a command to its appropriate handler in the current process.

Parameters

  • $command mixed
  • $handler mixed
public

dispatchToQueue ( $command ) : mixed

Dispatch a command to its appropriate handler behind a queue.

Parameters

  • $command mixed
public

dispatchAfterResponse ( $command ) : mixed

Dispatch a command to its appropriate handler.

Parameters

  • $command mixed
public

chain ( $jobs ) : PendingChain

Create a new chain of queueable jobs.

Parameters

  • $jobs Illuminate\...\Collection|array
public

findBatch ( string $batchId ) : Batch |null

Attempt to find the batch with the given ID.

Parameters

  • $batchId string
public

batch ( $jobs ) : PendingBatch

Create a new batch of queueable jobs.

Parameters

  • $jobs Illuminate\...\Collection|array
public

dispatchFakeBatch ( $name ) : Batch

Dispatch an empty job batch for testing.

Parameters

  • $name string
public

recordPendingBatch ( PendingBatch $pendingBatch ) : Batch

Record the fake pending batch dispatch.

Parameters

protected

shouldFakeJob ( $command ) : bool

Determine if a command should be faked or actually dispatched.

Parameters

  • $command mixed
protected

shouldDispatchCommand ( $command ) : bool

Determine if a command should be dispatched or not.

Parameters

  • $command mixed
public

pipeThrough ( array $pipes ) : $this

Set the pipes commands should be piped through before dispatching.

Parameters

  • $pipes array
public

hasCommandHandler ( $command ) : bool

Determine if the given command has a handler.

Parameters

  • $command mixed
public

getCommandHandler ( $command ) : mixed

Retrieve the handler for a command.

Parameters

  • $command mixed
public

map ( array $map ) : $this

Map a command to a handler.

Parameters

  • $map array