mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
General Coding Convention Changes
This commit is contained in:
parent
f5957a0586
commit
26f47d9d58
@ -68,76 +68,62 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
*
|
*
|
||||||
* @param array $parameters context parameters (set them up through behat.yml)
|
* @param array $parameters context parameters (set them up through behat.yml)
|
||||||
*/
|
*/
|
||||||
public function __construct(array $parameters)
|
public function __construct(array $parameters) {
|
||||||
{
|
|
||||||
// Initialize your context here
|
// Initialize your context here
|
||||||
$this->context = $parameters;
|
$this->context = $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDatabase($databaseName)
|
public function setDatabase($databaseName) {
|
||||||
{
|
|
||||||
$this->databaseName = $databaseName;
|
$this->databaseName = $databaseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAjaxSteps($ajaxSteps)
|
public function setAjaxSteps($ajaxSteps) {
|
||||||
{
|
|
||||||
if($ajaxSteps) $this->ajaxSteps = $ajaxSteps;
|
if($ajaxSteps) $this->ajaxSteps = $ajaxSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAjaxSteps()
|
public function getAjaxSteps() {
|
||||||
{
|
|
||||||
return $this->ajaxSteps;
|
return $this->ajaxSteps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAjaxTimeout($ajaxTimeout)
|
public function setAjaxTimeout($ajaxTimeout) {
|
||||||
{
|
|
||||||
$this->ajaxTimeout = $ajaxTimeout;
|
$this->ajaxTimeout = $ajaxTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAjaxTimeout()
|
public function getAjaxTimeout() {
|
||||||
{
|
|
||||||
return $this->ajaxTimeout;
|
return $this->ajaxTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAdminUrl($adminUrl)
|
public function setAdminUrl($adminUrl) {
|
||||||
{
|
|
||||||
$this->adminUrl = $adminUrl;
|
$this->adminUrl = $adminUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdminUrl()
|
public function getAdminUrl() {
|
||||||
{
|
|
||||||
return $this->adminUrl;
|
return $this->adminUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLoginUrl($loginUrl)
|
public function setLoginUrl($loginUrl) {
|
||||||
{
|
|
||||||
$this->loginUrl = $loginUrl;
|
$this->loginUrl = $loginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLoginUrl()
|
public function getLoginUrl() {
|
||||||
{
|
|
||||||
return $this->loginUrl;
|
return $this->loginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setScreenshotPath($screenshotPath)
|
public function setScreenshotPath($screenshotPath) {
|
||||||
{
|
|
||||||
$this->screenshotPath = $screenshotPath;
|
$this->screenshotPath = $screenshotPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getScreenshotPath()
|
public function getScreenshotPath() {
|
||||||
{
|
|
||||||
return $this->screenshotPath;
|
return $this->screenshotPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BeforeScenario
|
* @BeforeScenario
|
||||||
*/
|
*/
|
||||||
public function before(ScenarioEvent $event)
|
public function before(ScenarioEvent $event) {
|
||||||
{
|
|
||||||
if (!isset($this->databaseName)) {
|
if (!isset($this->databaseName)) {
|
||||||
throw new \LogicException(
|
throw new \LogicException(
|
||||||
'Context\'s $databaseName has to be set when implementing '
|
'Context\'s $databaseName has to be set when implementing SilverStripeAwareContextInterface.'
|
||||||
. 'SilverStripeAwareContextInterface.'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +137,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
if(!preg_match('/<!-- +SUCCESS: +DBNAME=([^ ]+)/i', $content, $matches)) {
|
if(!preg_match('/<!-- +SUCCESS: +DBNAME=([^ ]+)/i', $content, $matches)) {
|
||||||
throw new \LogicException("Could not create a test session. Details below:\n" . $content);
|
throw new \LogicException("Could not create a test session. Details below:\n" . $content);
|
||||||
|
|
||||||
} else if($matches[1] != $this->databaseName) {
|
} elseif($matches[1] != $this->databaseName) {
|
||||||
throw new \LogicException("Test session is using the database $matches[1]; it should be using $this->databaseName.");
|
throw new \LogicException("Test session is using the database $matches[1]; it should be using $this->databaseName.");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -183,8 +169,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
* @param $url
|
* @param $url
|
||||||
* @return array|mixed Parsed URL
|
* @return array|mixed Parsed URL
|
||||||
*/
|
*/
|
||||||
public function parseUrl($url)
|
public function parseUrl($url) {
|
||||||
{
|
|
||||||
$url = parse_url($url);
|
$url = parse_url($url);
|
||||||
$url['vars'] = array();
|
$url['vars'] = array();
|
||||||
if (!isset($url['fragment'])) {
|
if (!isset($url['fragment'])) {
|
||||||
@ -205,8 +190,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
* @param $url string URL to compare to current URL
|
* @param $url string URL to compare to current URL
|
||||||
* @return boolean Returns true if the current URL is close enough to the given URL, false otherwise.
|
* @return boolean Returns true if the current URL is close enough to the given URL, false otherwise.
|
||||||
*/
|
*/
|
||||||
public function isCurrentUrlSimilarTo($url)
|
public function isCurrentUrlSimilarTo($url) {
|
||||||
{
|
|
||||||
$current = $this->parseUrl($this->getSession()->getCurrentUrl());
|
$current = $this->parseUrl($this->getSession()->getCurrentUrl());
|
||||||
$test = $this->parseUrl($url);
|
$test = $this->parseUrl($url);
|
||||||
|
|
||||||
@ -234,8 +218,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getBaseUrl()
|
public function getBaseUrl() {
|
||||||
{
|
|
||||||
return $this->getMinkParameter('base_url') ?: '';
|
return $this->getMinkParameter('base_url') ?: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +231,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function joinUrlParts()
|
public function joinUrlParts() {
|
||||||
{
|
|
||||||
if (0 === func_num_args()) {
|
if (0 === func_num_args()) {
|
||||||
throw new \InvalidArgumentException('Need at least one argument');
|
throw new \InvalidArgumentException('Need at least one argument');
|
||||||
}
|
}
|
||||||
@ -263,8 +245,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
return implode('/', $parts);
|
return implode('/', $parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canIntercept()
|
public function canIntercept() {
|
||||||
{
|
|
||||||
$driver = $this->getSession()->getDriver();
|
$driver = $this->getSession()->getDriver();
|
||||||
if ($driver instanceof GoutteDriver) {
|
if ($driver instanceof GoutteDriver) {
|
||||||
return true;
|
return true;
|
||||||
@ -275,14 +256,14 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new UnsupportedDriverActionException('You need to tag the scenario with "@mink:goutte" or "@mink:symfony". Intercepting the redirections is not supported by %s', $driver);
|
throw new UnsupportedDriverActionException('You need to tag the scenario with "@mink:goutte" or
|
||||||
|
"@mink:symfony". Intercepting the redirections is not supported by %s', $driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^(.*) without redirection$/
|
* @Given /^(.*) without redirection$/
|
||||||
*/
|
*/
|
||||||
public function theRedirectionsAreIntercepted($step)
|
public function theRedirectionsAreIntercepted($step) {
|
||||||
{
|
|
||||||
if ($this->canIntercept()) {
|
if ($this->canIntercept()) {
|
||||||
$this->getSession()->getDriver()->getClient()->followRedirects(false);
|
$this->getSession()->getDriver()->getClient()->followRedirects(false);
|
||||||
}
|
}
|
||||||
@ -294,8 +275,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
* Fills in form field with specified id|name|label|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
|
* Overwritten to select the first *visible* element, see https://github.com/Behat/Mink/issues/311
|
||||||
*/
|
*/
|
||||||
public function fillField($field, $value)
|
public function fillField($field, $value) {
|
||||||
{
|
|
||||||
$value = $this->fixStepArgument($value);
|
$value = $this->fixStepArgument($value);
|
||||||
$fields = $this->getSession()->getPage()->findAll('named', array(
|
$fields = $this->getSession()->getPage()->findAll('named', array(
|
||||||
'field', $this->getSession()->getSelectorsHandler()->xpathLiteral($field)
|
'field', $this->getSession()->getSelectorsHandler()->xpathLiteral($field)
|
||||||
@ -315,8 +295,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
/**
|
/**
|
||||||
* Overwritten to click the first *visable* link the DOM.
|
* Overwritten to click the first *visable* link the DOM.
|
||||||
*/
|
*/
|
||||||
public function clickLink($link)
|
public function clickLink($link) {
|
||||||
{
|
|
||||||
$link = $this->fixStepArgument($link);
|
$link = $this->fixStepArgument($link);
|
||||||
$links = $this->getSession()->getPage()->findAll('named', array(
|
$links = $this->getSession()->getPage()->findAll('named', array(
|
||||||
'link', $this->getSession()->getSelectorsHandler()->xpathLiteral($link)
|
'link', $this->getSession()->getSelectorsHandler()->xpathLiteral($link)
|
||||||
|
Loading…
Reference in New Issue
Block a user