Scenario
    
            
            in package
            
        
    
    
    
        
            The scenario is the core of an Artillery test script. It defines the flow of requests.
It has all methods related to a scenario and its flow.
Tags
Table of Contents
- addAfterResponse() : $this
 - Add a function or array of functions to be executed after a response is received.
 - addAfterScenario() : $this
 - Add a function or array of functions from the JavaScript file defined with Artillery::setProcessor to be run at the end of this scenario.
 - addBeforeRequest() : $this
 - Add a function or array of functions to be executed after a scenario is finished.
 - addBeforeScenario() : $this
 - Add a function or array of functions from the JavaScript file defined with Artillery::setProcessor to be run at the start of this scenario.
 - addFlow() : $this
 - Add/merge the flow of another Scenario into this scenario's flow.
 - addFunction() : $this
 - Adds a function or array of functions from the JavaScript file defined with Artillery::setProcessor() to be executed at this point in the Scenario's flow.
 - addLog() : $this
 - Adds a log to the flow which will print messages to the console at this point in the flow.
 - addLoop() : $this
 - Adds a loop to the flow, which can be another Scenario, a request or an array of either.
 - addRequest() : $this
 - Add a request object directly to this scenario's flow.
 - addRequests() : $this
 - Add an array of request objects directly to this scenario's flow.
 - addThink() : $this
 - Adds a pause segment to the flow to pause the virtual user for N seconds.
 - set() : $this
 - Set an arbitrary custom option in this scenario.
 - setEngine() : $this
 - Set an engine to use for this scenario, if it's ot set then the HTTP engine will be used.
 - setName() : $this
 - Set the name of this scenario for metrics and reporting.
 - setWeight() : $this
 - Set the weight chance to be picked for this scenario when its weight is compared to that of other scenarios added to the Artillery script.
 
Methods
addAfterResponse()
Add a function or array of functions to be executed after a response is received.
    public
                    addAfterResponse(string|array<string|int, string> $function) : $this
    
        Parameters
- $function : string|array<string|int, string>
 - 
                    
The function(s) to execute.
 
Tags
Return values
$this —The current Request instance.
addAfterScenario()
Add a function or array of functions from the JavaScript file defined with Artillery::setProcessor to be run at the end of this scenario.
    public
                    addAfterScenario(string|array<string|int, string> $function) : $this
    
        Parameters
- $function : string|array<string|int, string>
 - 
                    
The function or array of functions to add.
 
Tags
Return values
$this —The current Scenario instance.
addBeforeRequest()
Add a function or array of functions to be executed after a scenario is finished.
    public
                    addBeforeRequest(string|array<string|int, string> $function) : $this
    
        Parameters
- $function : string|array<string|int, string>
 - 
                    
The function(s) to execute.
 
Tags
Return values
$this —The current Request instance.
addBeforeScenario()
Add a function or array of functions from the JavaScript file defined with Artillery::setProcessor to be run at the start of this scenario.
    public
                    addBeforeScenario(string|array<string|int, string> $function) : $this
    
        Parameters
- $function : string|array<string|int, string>
 - 
                    
The function or array of functions to add.
 
Tags
Return values
$this —The current Scenario instance.
addFlow()
Add/merge the flow of another Scenario into this scenario's flow.
    public
                    addFlow(Scenario $scenario) : $this
    
        Parameters
- $scenario : Scenario
 - 
                    
The Scenario from which flow to add to this Scenario's flow.
 
Tags
Return values
$this —The current Scenario instance.
addFunction()
Adds a function or array of functions from the JavaScript file defined with Artillery::setProcessor() to be executed at this point in the Scenario's flow.
    public
                    addFunction(string|array<string|int, string> $function[, string|null $ifTrue = null ]) : $this
    
        Parameters
- $function : string|array<string|int, string>
 - 
                    
The function to add.
 - $ifTrue : string|null = null
 - 
                    
The condition for this function to be run
 
Tags
Return values
$this —The current Scenario instance.
addLog()
Adds a log to the flow which will print messages to the console at this point in the flow.
    public
                    addLog(string $message[, string|null $ifTrue = null ]) : $this
    
        Parameters
- $message : string
 - 
                    
The message to log once this part of the flow is reached.
 - $ifTrue : string|null = null
 - 
                    
The condition for this log.
 
Tags
Return values
$this —The current Scenario instance.
addLoop()
Adds a loop to the flow, which can be another Scenario, a request or an array of either.
    public
                    addLoop(Scenario|RequestInterface|array<string|int, \ArtilleryPhp\Scenario|\ArtilleryPhp\RequestInterface> $loop[, int|null $count = null ][, string|null $over = null ][, string|null $whileTrue = null ]) : $this
        To make it even more fun, loops can be nested.
Parameters
- $loop : Scenario|RequestInterface|array<string|int, \ArtilleryPhp\Scenario|\ArtilleryPhp\RequestInterface>
 - 
                    
A Scenario, Request or array containing these types.
 - $count : int|null = null
 - 
                    
The number of times to loop.
 - $over : string|null = null
 - 
                    
The variable reference to loop over.
 - $whileTrue : string|null = null
 - 
                    
The condition to continue looping.
 
Tags
Return values
$this —The current Scenario instance.
addRequest()
Add a request object directly to this scenario's flow.
    public
                    addRequest(RequestInterface $request) : $this
    
        Parameters
- $request : RequestInterface
 - 
                    
The request to add.
 
Tags
Return values
$this —The current Scenario instance.
addRequests()
Add an array of request objects directly to this scenario's flow.
    public
                    addRequests(array<string|int, RequestInterface> $requests) : $this
    
        Parameters
- $requests : array<string|int, RequestInterface>
 - 
                    
The requests to add.
 
Tags
Return values
$this —The current Scenario instance.
addThink()
Adds a pause segment to the flow to pause the virtual user for N seconds.
    public
                    addThink(float $duration[, string|null $ifTrue = null ]) : $this
    
        Parameters
- $duration : float
 - 
                    
The duration of the pause in seconds.
 - $ifTrue : string|null = null
 - 
                    
The condition for this pause to be run
 
Tags
Return values
$this —The current Scenario instance.
set()
Set an arbitrary custom option in this scenario.
    public
                    set(string $key, mixed $value) : $this
    
        Parameters
- $key : string
 - 
                    
The name of the option.
 - $value : mixed
 - 
                    
The value of the option.
 
Tags
Return values
$this —The current Scenario instance.
setEngine()
Set an engine to use for this scenario, if it's ot set then the HTTP engine will be used.
    public
                    setEngine(string $engine) : $this
        If 'ws' is set, then you must only use WsRequest in this Scenario.
Parameters
- $engine : string
 - 
                    
Desired engine to use in this scenario.
 
Tags
Return values
$this —The current Scenario instance.
setName()
Set the name of this scenario for metrics and reporting.
    public
                    setName(string $name) : $this
    
        Parameters
- $name : string
 - 
                    
The name of this scenario.
 
Return values
$this —The current Scenario instance.
setWeight()
Set the weight chance to be picked for this scenario when its weight is compared to that of other scenarios added to the Artillery script.
    public
                    setWeight(int $weight) : $this
    
        Parameters
- $weight : int
 - 
                    
The weight of this scenario.
 
Tags
Return values
$this —The current Scenario instance.