PHP Class DataSift\Storyplayer\PlayerLib\Story

Datei anzeigen Open project: datasift/storyplayer Class Usage Examples

Protected Properties

Property Type Description
$actionsCallbacks array this is an array of callbacks. Each callback is a single set of actions to execute the story. Each callback is an alternative way to execute the story. Each callback is meant to be equivalent; ie they achieve the same thing, just in different ways. If any of the callbacks has different outcomes, then they belong in separate user stories. NO EXCEPTIONS. This is a fundamental assumption of Storyplayer; ignore it, and Storyplayer's no use to you!
$category string the category that this story belongs to
$compatibleVersion integer you HAVE to set this in your story, otherwise we will skip your story
$deviceSetupCallback array the function that provides any story-specific setup work that happens when we start a device
$deviceTeardownCallback array the function that provides any story-specific teardown work that happens just before we stop a device
$group array the group that this story belongs to
$hintsCallback callable the function that provides hints about how this story changes the state of the system or user
$name string the name of this story
$params array the parameters that get passed into virtual machines et al, and which can be overridden on the command-line
$parserTrees array the raw parser tree of this story, and of any templates that we use
$perPhaseSetupCallback array the function that provides any story-specific setup work that happens before each phase of the test
$perPhaseTeardownCallback array the function that provides any story-specific teardown work that happens at the end of each phase of the test
$persistDevice boolean does the story want the test device kept open between phases?
$postTestInspectionCallback array the callback used to see if the action *did* change the state of the system under test
$preTestInspectionCallback array the callback used to remember the state of the system *before* the action occurs
$preTestPredictionCallback array the callback that dynamically determines in advance whether the story actions should succeed or fail
$reportTestResultsCallback array the callback that dynamically determines afterwards whether or not the story actions actually did succeed
$requiredTestEnvRoles array a list of the roles that the test environment must have defined, otherwise we cannot run
$roleChangesCallback array the function that provides information about how this story has changed the state of the system or user
$storyFilename string the file that contains the story
$storyResult Story_Result what happened to this story?
$storyTemplates array a list of the StoryTemplates that this story is based on. can be empty
$testCanRunCheckCallback array the function that checks to see if the test should run at all, or should be skipped
$testSetupCallback array the function that provides any story-specific setup work
$testTeardownCallback array the function that provides any story-specific teardown action
$whitelistedEnvironments by default, a story is allowed to run on all environments, *but* if an environment's config sets 'mustBeWhitelisted' to TRUE, then the story is only allowed to run on that environment if the story declares itself safe to run we believe that this is the safest approach to handling those stories that simply aren't safe to run absolutely everywhere

Public Methods

Method Description
__toString ( ) : string return a string representation of the story, for things like logging
addAction ( $newCallback ) : void
addActions ( $newCallback ) : void
addDeviceSetup ( $newCallback ) : void
addDeviceTeardown ( $newCallback ) : void
addHints ( $newCallback ) : void
addPerPhaseSetup ( $newCallback ) : void
addPerPhaseTeardown ( $newCallback ) : void
addPostTestInspection ( $newCallback ) : void
addPreTestInspection ( $newCallback ) : void
addPreTestPrediction ( $newCallback ) : void
addTestCanRunCheck ( $newCallback ) : void
addTestEnvironmentSetup ( $newCallback )
addTestEnvironmentTeardown ( $newCallback )
addTestSetup ( $newCallback )
addTestTeardown ( $newCallback ) : void
addValidRole ( $role ) --------------------------------------------------------------------
andOn ( $envName ) : Story
andValidRole ( $role ) Synonym for addValidRole()
basedOn ( StoryTemplate $tmpl ) : Story set up any templated methods from a predefined class
called ( $userStoryText ) : Story
determineStoryFilename ( ) : void
generateGroup ( ) : Story Set the group name as the file system path of the directory where the test is located
generateName ( ) : Story Set the name as the filename of the test
getCategory ( ) : string Get the category that this story belongs to
getDeviceSetup ( ) : array get the callback for device setup work
getDeviceTeardown ( ) : array get the callback for device teardown work
getGroup ( ) : array Get the group that this story belongs to
getGroupAsString ( ) : string return the story's group as a printable string
getHints ( ) : callable get the hints callback
getName ( ) : string Get the name of this story
getOneAction ( ) : callable pick one action at random, and return it to the caller
getParams ( ) : array
getPerPhaseSetup ( ) : array get the callback for per-phase setup work
getPerPhaseTeardown ( ) : array get the callback for per-phase teardown work
getPersistDevice ( ) : boolean does this story want to keep the web browser open between phases?
getPostTestInspection ( ) : array get the callback to use to work out the test results
getPreTestInspection ( ) : array get the callback to use to perform the preflight checkpoint
getPreTestPrediction ( ) : array get the callback to use to perform the preflight checks
getRequiredStoryplayerVersion ( ) : integer
getRequiredTestEnvironmentRoles ( ) : array
getResult ( ) : Story_Result
getRoleChanges ( ) get the role changes callback
getStoryFilename ( ) : string
getStoryTemplates ( ) : array get a list of the templates that this story is based on, in order or precedence
getTestCanRunCheck ( ) : array get the callback which allows the story to be skipped
getTestSetup ( ) : array get the callback for per-story setup work
getTestTeardown ( ) : array get the callback for post-story teardown work
getWhitelistedEnvironments ( ) : array
hasActions ( ) : boolean does this story have any actions?
hasDeviceSetup ( ) : boolean do we have a device setup callback?
hasDeviceTeardown ( ) : boolean do we have a device teardown callback?
hasHints ( ) : boolean have any hints been set?
hasPerPhaseSetup ( ) : boolean do we have a per-phase setup callback?
hasPerPhaseTeardown ( ) : boolean do we have a per-phase teardown callback?
hasPostTestInspection ( ) : boolean
hasPreTestInspection ( ) : boolean do we have a callback
hasPreTestPrediction ( ) : boolean do we have a callback
hasRole ( $roleName )
hasRoleChanges ( ) has the role changes callback been set?
hasTestCanRunCheck ( ) : boolean do we have a 'check story can run' callback?
hasTestSetup ( ) : boolean do we have a pre-story setup callback?
hasTestTeardown ( ) : boolean do we have a post-story teardown callback?
inGroup ( array | string $groupName ) : Story which group of tests does this story belong to?
requiresStoryplayerVersion ( $version ) : Story
requiresTestEnvironmentWithRoles ( $roles ) : void
runsOn ( $envName ) : Story
setCategory ( string $newCategory ) : Story Set the category that this story belongs to
setDefaultCallbacks ( ) : void
setGroup ( array $newGroup ) : Story Set the group that this story belongs to
setHints ( $newCallback ) : void
setName ( string $newName ) : Story Set the name of this story
setParams ( array $defaults ) Set the parameters for this story
setPersistDevice ( ) tell Storyplayer to keep the web browser open between test phases
setRoleChanges ( $newCallback )
setTestEnvironmentSetup ( $newCallback ) --------------------------------------------------------------------
setTestEnvironmentTeardown ( $newCallback )

Method Details

__toString() public method

return a string representation of the story, for things like logging
public __toString ( ) : string
return string

addAction() public method

public addAction ( $newCallback ) : void
return void

addActions() public method

public addActions ( $newCallback ) : void
return void

addDeviceSetup() public method

public addDeviceSetup ( $newCallback ) : void
return void

addDeviceTeardown() public method

public addDeviceTeardown ( $newCallback ) : void
return void

addHints() public method

public addHints ( $newCallback ) : void
return void

addPerPhaseSetup() public method

public addPerPhaseSetup ( $newCallback ) : void
return void

addPerPhaseTeardown() public method

public addPerPhaseTeardown ( $newCallback ) : void
return void

addPostTestInspection() public method

public addPostTestInspection ( $newCallback ) : void
return void

addPreTestInspection() public method

public addPreTestInspection ( $newCallback ) : void
return void

addPreTestPrediction() public method

public addPreTestPrediction ( $newCallback ) : void
return void

addTestCanRunCheck() public method

public addTestCanRunCheck ( $newCallback ) : void
return void

addTestEnvironmentSetup() public method

public addTestEnvironmentSetup ( $newCallback )

addTestEnvironmentTeardown() public method

public addTestEnvironmentTeardown ( $newCallback )

addTestSetup() public method

public addTestSetup ( $newCallback )

addTestTeardown() public method

public addTestTeardown ( $newCallback ) : void
return void

addValidRole() public method

--------------------------------------------------------------------
public addValidRole ( $role )

andOn() public method

public andOn ( $envName ) : Story
return Story

andValidRole() public method

Synonym for addValidRole()
See also: Story::addValidRole
public andValidRole ( $role )

basedOn() public method

set up any templated methods from a predefined class
public basedOn ( StoryTemplate $tmpl ) : Story
$tmpl StoryTemplate
return Story

called() public method

public called ( $userStoryText ) : Story
return Story

determineStoryFilename() public method

public determineStoryFilename ( ) : void
return void

generateGroup() public method

Set the group name as the file system path of the directory where the test is located
public generateGroup ( ) : Story
return Story $this for fluent interface

generateName() public method

Set the name as the filename of the test
public generateName ( ) : Story
return Story $this for fluent interface

getCategory() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public getCategory ( ) : string
return string the category that this story belongs to

getDeviceSetup() public method

get the callback for device setup work
public getDeviceSetup ( ) : array
return array

getDeviceTeardown() public method

get the callback for device teardown work
public getDeviceTeardown ( ) : array
return array

getGroup() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public getGroup ( ) : array
return array

getGroupAsString() public method

return the story's group as a printable string
public getGroupAsString ( ) : string
return string

getHints() public method

get the hints callback
public getHints ( ) : callable
return callable

getName() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public getName ( ) : string
return string the name of this story

getOneAction() public method

pick one action at random, and return it to the caller
public getOneAction ( ) : callable
return callable

getParams() public method

public getParams ( ) : array
return array

getPerPhaseSetup() public method

get the callback for per-phase setup work
public getPerPhaseSetup ( ) : array
return array

getPerPhaseTeardown() public method

get the callback for per-phase teardown work
public getPerPhaseTeardown ( ) : array
return array

getPersistDevice() public method

does this story want to keep the web browser open between phases?
public getPersistDevice ( ) : boolean
return boolean

getPostTestInspection() public method

get the callback to use to work out the test results
public getPostTestInspection ( ) : array
return array

getPreTestInspection() public method

get the callback to use to perform the preflight checkpoint
public getPreTestInspection ( ) : array
return array

getPreTestPrediction() public method

get the callback to use to perform the preflight checks
public getPreTestPrediction ( ) : array
return array

getRequiredStoryplayerVersion() public method

getRequiredTestEnvironmentRoles() public method

getResult() public method

public getResult ( ) : Story_Result
return Story_Result

getRoleChanges() public method

get the role changes callback
public getRoleChanges ( )

getStoryFilename() public method

public getStoryFilename ( ) : string
return string

getStoryTemplates() public method

can be empty
public getStoryTemplates ( ) : array
return array

getTestCanRunCheck() public method

get the callback which allows the story to be skipped
public getTestCanRunCheck ( ) : array
return array

getTestSetup() public method

get the callback for per-story setup work
public getTestSetup ( ) : array
return array

getTestTeardown() public method

get the callback for post-story teardown work
public getTestTeardown ( ) : array
return array

getWhitelistedEnvironments() public method

public getWhitelistedEnvironments ( ) : array
return array

hasActions() public method

does this story have any actions?
public hasActions ( ) : boolean
return boolean true if this story has any actions

hasDeviceSetup() public method

do we have a device setup callback?
public hasDeviceSetup ( ) : boolean
return boolean true if there is a device setup callback

hasDeviceTeardown() public method

do we have a device teardown callback?
public hasDeviceTeardown ( ) : boolean
return boolean true if there is a device teardown callback

hasHints() public method

have any hints been set?
public hasHints ( ) : boolean
return boolean true if the callback has been set

hasPerPhaseSetup() public method

do we have a per-phase setup callback?
public hasPerPhaseSetup ( ) : boolean
return boolean true if there is a per-phase setup callback

hasPerPhaseTeardown() public method

do we have a per-phase teardown callback?
public hasPerPhaseTeardown ( ) : boolean
return boolean true if there is a per-phase teardown callback

hasPostTestInspection() public method

public hasPostTestInspection ( ) : boolean
return boolean

hasPreTestInspection() public method

do we have a callback
public hasPreTestInspection ( ) : boolean
return boolean [description]

hasPreTestPrediction() public method

do we have a callback
public hasPreTestPrediction ( ) : boolean
return boolean [description]

hasRole() public method

public hasRole ( $roleName )

hasRoleChanges() public method

has the role changes callback been set?
public hasRoleChanges ( )

hasTestCanRunCheck() public method

do we have a 'check story can run' callback?
public hasTestCanRunCheck ( ) : boolean
return boolean true if the callback exists

hasTestSetup() public method

do we have a pre-story setup callback?
public hasTestSetup ( ) : boolean
return boolean true if there is a pre-story setup callback

hasTestTeardown() public method

do we have a post-story teardown callback?
public hasTestTeardown ( ) : boolean
return boolean true if there is a post-story teardown callback

inGroup() public method

which group of tests does this story belong to?
public inGroup ( array | string $groupName ) : Story
$groupName array | string the group to use
return Story $this for fluent interface

requiresStoryplayerVersion() public method

public requiresStoryplayerVersion ( $version ) : Story
return Story

requiresTestEnvironmentWithRoles() public method

public requiresTestEnvironmentWithRoles ( $roles ) : void
return void

runsOn() public method

public runsOn ( $envName ) : Story
return Story

setCategory() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public setCategory ( string $newCategory ) : Story
$newCategory string the category that this story belongs to
return Story $this

setDefaultCallbacks() public method

public setDefaultCallbacks ( ) : void
return void

setGroup() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public setGroup ( array $newGroup ) : Story
$newGroup array
return Story $this

setHints() public method

public setHints ( $newCallback ) : void
return void

setName() public method

Systems under test can grow to encompass hundreds, if not thousands of user stories. To make this manageable at scale, we break down each user story like this: Name : Starts as a free user with 10 USD in credit Category: Billing User Stories Group : User States The 'name' is the summary text of the user story itself, which should be no longer than a single sentence, please. The 'category' is the general group that the user story belongs to. These are the top-level groups, such as 'Registration', 'Billing' and so forth. The 'group' is the specific group _inside_ the category that the user story belongs to. The groups are specific to the category.
public setName ( string $newName ) : Story
$newName string the name of this story
return Story $this

setParams() public method

Parameters are a way of passing settings between Stories and StoryTemplates. Order of precedence: 1) Story 2) StoryTemplates (in 'basedOn()' order) (templates cannot override each other)
public setParams ( array $defaults )
$defaults array a list of the parameters for this story

setPersistDevice() public method

by default, we close the browser after every phase, to make sure that the next phase always starts with a browser in a known state
public setPersistDevice ( )

setRoleChanges() public method

public setRoleChanges ( $newCallback )

setTestEnvironmentSetup() public method

--------------------------------------------------------------------
public setTestEnvironmentSetup ( $newCallback )

setTestEnvironmentTeardown() public method

public setTestEnvironmentTeardown ( $newCallback )

Property Details

$actionsCallbacks protected_oe property

this is an array of callbacks. Each callback is a single set of actions to execute the story. Each callback is an alternative way to execute the story. Each callback is meant to be equivalent; ie they achieve the same thing, just in different ways. If any of the callbacks has different outcomes, then they belong in separate user stories. NO EXCEPTIONS. This is a fundamental assumption of Storyplayer; ignore it, and Storyplayer's no use to you!
protected array $actionsCallbacks
return array

$category protected_oe property

the category that this story belongs to
protected string $category
return string

$compatibleVersion protected_oe property

you HAVE to set this in your story, otherwise we will skip your story
protected int $compatibleVersion
return integer

$deviceSetupCallback protected_oe property

the function that provides any story-specific setup work that happens when we start a device
protected array $deviceSetupCallback
return array

$deviceTeardownCallback protected_oe property

the function that provides any story-specific teardown work that happens just before we stop a device
protected array $deviceTeardownCallback
return array

$group protected_oe property

the group that this story belongs to
protected array $group
return array

$hintsCallback protected_oe property

the function that provides hints about how this story changes the state of the system or user
protected callable $hintsCallback
return callable

$name protected_oe property

the name of this story
protected string $name
return string

$params protected_oe property

the parameters that get passed into virtual machines et al, and which can be overridden on the command-line
protected array $params
return array

$parserTrees protected_oe property

the raw parser tree of this story, and of any templates that we use
protected array $parserTrees
return array

$perPhaseSetupCallback protected_oe property

the function that provides any story-specific setup work that happens before each phase of the test
protected array $perPhaseSetupCallback
return array

$perPhaseTeardownCallback protected_oe property

the function that provides any story-specific teardown work that happens at the end of each phase of the test
protected array $perPhaseTeardownCallback
return array

$persistDevice protected_oe property

does the story want the test device kept open between phases?
protected bool $persistDevice
return boolean

$postTestInspectionCallback protected_oe property

the callback used to see if the action *did* change the state of the system under test
protected array $postTestInspectionCallback
return array

$preTestInspectionCallback protected_oe property

the callback used to remember the state of the system *before* the action occurs
protected array $preTestInspectionCallback
return array

$preTestPredictionCallback protected_oe property

the callback that dynamically determines in advance whether the story actions should succeed or fail
protected array $preTestPredictionCallback
return array

$reportTestResultsCallback protected_oe property

the callback that dynamically determines afterwards whether or not the story actions actually did succeed
protected array $reportTestResultsCallback
return array

$requiredTestEnvRoles protected_oe property

a list of the roles that the test environment must have defined, otherwise we cannot run
protected array $requiredTestEnvRoles
return array

$roleChangesCallback protected_oe property

the function that provides information about how this story has changed the state of the system or user
protected array $roleChangesCallback
return array

$storyFilename protected_oe property

the file that contains the story
protected string $storyFilename
return string

$storyResult protected_oe property

what happened to this story?
protected Story_Result,DataSift\Storyplayer\PlayerLib $storyResult
return Story_Result

$storyTemplates protected_oe property

a list of the StoryTemplates that this story is based on. can be empty
protected array $storyTemplates
return array

$testCanRunCheckCallback protected_oe property

the function that checks to see if the test should run at all, or should be skipped
protected array $testCanRunCheckCallback
return array

$testSetupCallback protected_oe property

the function that provides any story-specific setup work
protected array $testSetupCallback
return array

$testTeardownCallback protected_oe property

the function that provides any story-specific teardown action
protected array $testTeardownCallback
return array

$whitelistedEnvironments protected_oe property

by default, a story is allowed to run on all environments, *but* if an environment's config sets 'mustBeWhitelisted' to TRUE, then the story is only allowed to run on that environment if the story declares itself safe to run we believe that this is the safest approach to handling those stories that simply aren't safe to run absolutely everywhere
protected $whitelistedEnvironments