abstract class SilverStripeContext extends MinkContext implements SilverStripeAwareContext (View source)

SilverStripeContext

Generic context wrapper used as a base for Behat FeatureContext.

The default context for each module should extend this and be named FeatureContext under the standard module namespace.

Properties

protected $databaseName
protected array $ajaxSteps
protected int $ajaxTimeout
protected string $adminUrl
protected string $loginUrl
protected string $screenshotPath
protected TestSessionEnvironment $testSessionEnvironment
protected $regionMap
protected Escaper $xpathEscaper

XPath escaper

Methods

public
__construct(array $parameters = null)

Initializes context.

public
Escaper
getXpathEscaper()

Get xpath escaper

public
setDatabase(string $databaseName)

Sets SilverStripe instance.

public
setAjaxSteps(array $ajaxSteps)

Marks steps as AJAX steps for special treatment

public
getAjaxSteps()

No description

public
setAjaxTimeout(int $ajaxTimeout)

Set timeout in millisceonds

public
getAjaxTimeout()

No description

public
setAdminUrl(string $adminUrl)

Set admin url

public
getAdminUrl()

No description

public
setLoginUrl(string $loginUrl)

Set login url

public
getLoginUrl()

No description

public
setScreenshotPath(string $screenshotPath)

Set path to screenshots dir

public
getScreenshotPath()

No description

public
getRegionMap()

No description

public
setRegionMap($regionMap)

I have no idea

public
NodeElement
getRegionObj(string $region)

Returns NodeElement based off region defined in .yml file.

public
before(BeforeScenarioScope $event)

No description

public
waitResponsesAfterStep(AfterStepScope $event)

No description

public
array
getTestSessionState()

Returns a parameter map of state to set within the test session.

public
array|mixed
parseUrl($url)

Parses given URL and returns its components

public
bool
isCurrentUrlSimilarTo($url)

Checks whether current URL is close enough to the given URL.

public
string
getBaseUrl()

Returns base URL parameter set in MinkExtension.

public
string
joinUrlParts($part = null)

Joins URL parts into an URL using forward slash.

public
canIntercept()

No description

public
fillField(string $field, string $value)

Fills in form field with specified id|name|label|value.

public
clickLink(string $link)

Overwritten to click the first visible link the DOM.

public
givenTheCurrentDateIs(string $date)

Sets the current date. Relies on the underlying functionality using SS_Datetime::now() rather than PHP's system time methods like date().

public
givenTheCurrentTimeIs(string $time)

Sets the current time. Relies on the underlying functionality using \SS_Datetime::now() rather than PHP's system time methods like date().

public
selectOption(string $select, string $option)

Selects option in select field with specified id|name|label|value.

public
selectOptionWithJavascript(string $select, string $option)

Selects option in select field with specified id|name|label|value using javascript This method uses javascript to allow selection of options that may be overridden by javascript libraries, and thus hide the element.

Details

__construct(array $parameters = null)

Initializes context.

Every scenario gets it's own context object.

Parameters

array $parameters

context parameters (set them up through behat.yml)

Escaper getXpathEscaper()

Get xpath escaper

Return Value

Escaper

setDatabase(string $databaseName)

Sets SilverStripe instance.

Parameters

string $databaseName

Temp database name

setAjaxSteps(array $ajaxSteps)

Marks steps as AJAX steps for special treatment

Parameters

array $ajaxSteps

Array of step name parts to match

getAjaxSteps()

No description

setAjaxTimeout(int $ajaxTimeout)

Set timeout in millisceonds

Parameters

int $ajaxTimeout

getAjaxTimeout()

No description

setAdminUrl(string $adminUrl)

Set admin url

Parameters

string $adminUrl

getAdminUrl()

No description

setLoginUrl(string $loginUrl)

Set login url

Parameters

string $loginUrl

getLoginUrl()

No description

setScreenshotPath(string $screenshotPath)

Set path to screenshots dir

Parameters

string $screenshotPath

getScreenshotPath()

No description

getRegionMap()

No description

setRegionMap($regionMap)

I have no idea

Parameters

$regionMap

NodeElement getRegionObj(string $region)

Returns NodeElement based off region defined in .yml file.

Also supports direct CSS selectors and regions identified by a "data-title" attribute. When using the "data-title" attribute, ensure not to include double quotes.

Parameters

string $region

Region name or CSS selector

Return Value

NodeElement

Exceptions

ElementNotFoundException

before(BeforeScenarioScope $event)

No description

Parameters

BeforeScenarioScope $event

waitResponsesAfterStep(AfterStepScope $event)

No description

Parameters

AfterStepScope $event

array getTestSessionState()

Returns a parameter map of state to set within the test session.

Takes TESTSESSION_PARAMS environment variable into account for run-specific configurations.

Return Value

array

array|mixed parseUrl($url)

Parses given URL and returns its components

Parameters

$url

Return Value

array|mixed

Parsed URL

bool isCurrentUrlSimilarTo($url)

Checks whether current URL is close enough to the given URL.

Unless specified in $url, get vars will be ignored Unless specified in $url, fragment identifiers will be ignored

Parameters

$url

string URL to compare to current URL

Return Value

bool

Returns true if the current URL is close enough to the given URL, false otherwise.

string getBaseUrl()

Returns base URL parameter set in MinkExtension.

It simplifies configuration by allowing to specify this parameter once but makes code dependent on MinkExtension.

Return Value

string

string joinUrlParts($part = null)

Joins URL parts into an URL using forward slash.

Forward slash usages are normalised to one between parts. This method takes variable number of parameters.

Parameters

$part

Return Value

string

Exceptions

InvalidArgumentException

canIntercept()

No description

fillField(string $field, string $value)

Fills in form field with specified id|name|label|value.

Overwritten to select the first visible element, see https://github.com/Behat/Mink/issues/311

Parameters

string $field
string $value

Exceptions

ElementNotFoundException

Overwritten to click the first visible link the DOM.

Parameters

string $link

Exceptions

ElementNotFoundException

givenTheCurrentDateIs(string $date)

Sets the current date. Relies on the underlying functionality using SS_Datetime::now() rather than PHP's system time methods like date().

Supports ISO fomat: Y-m-d Example: Given the current date is "2009-10-31"

Parameters

string $date

givenTheCurrentTimeIs(string $time)

Sets the current time. Relies on the underlying functionality using \SS_Datetime::now() rather than PHP's system time methods like date().

Supports ISO fomat: H:i:s Example: Given the current time is "20:31:50"

Parameters

string $time

selectOption(string $select, string $option)

Selects option in select field with specified id|name|label|value.

Parameters

string $select
string $option

selectOptionWithJavascript(string $select, string $option)

Selects option in select field with specified id|name|label|value using javascript This method uses javascript to allow selection of options that may be overridden by javascript libraries, and thus hide the element.

Parameters

string $select
string $option

Exceptions

ElementNotFoundException