mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Fixed coding conventions (no functional changes)
Both Symfony and SilverStripe conventions mandate lower camel case for instance properties
This commit is contained in:
parent
f6d56e811a
commit
74e0d8cd83
@ -35,10 +35,10 @@ class MinkExtensionBaseUrlPass implements CompilerPassInterface
|
|||||||
if (!$container->hasParameter('behat.mink.base_url')) {
|
if (!$container->hasParameter('behat.mink.base_url')) {
|
||||||
throw new \Exception('MinkExtension improperly configured. Missing base_url parameter.');
|
throw new \Exception('MinkExtension improperly configured. Missing base_url parameter.');
|
||||||
}
|
}
|
||||||
$base_url = $container->getParameter('behat.mink.base_url');
|
$baseUrl = $container->getParameter('behat.mink.base_url');
|
||||||
if (empty($base_url)) {
|
if (empty($baseUrl)) {
|
||||||
throw new \Exception('MinkExtension improperly configured. Missing or empty base_url parameter.');
|
throw new \Exception('MinkExtension improperly configured. Missing or empty base_url parameter.');
|
||||||
}
|
}
|
||||||
$container->setParameter('behat.silverstripe_extension.framework_host', $base_url);
|
$container->setParameter('behat.silverstripe_extension.framework_host', $baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,10 +107,10 @@ JS;
|
|||||||
*/
|
*/
|
||||||
public function handleAjaxBeforeStep(StepEvent $event)
|
public function handleAjaxBeforeStep(StepEvent $event)
|
||||||
{
|
{
|
||||||
$ajax_enabled_steps = $this->getMainContext()->getAjaxSteps();
|
$ajaxEnabledSteps = $this->getMainContext()->getAjaxSteps();
|
||||||
$ajax_enabled_steps = implode('|', array_filter($ajax_enabled_steps));
|
$ajaxEnabledSteps = implode('|', array_filter($ajaxEnabledSteps));
|
||||||
|
|
||||||
if (empty($ajax_enabled_steps) || !preg_match('/(' . $ajax_enabled_steps . ')/i', $event->getStep()->getText())) {
|
if (empty($ajaxEnabledSteps) || !preg_match('/(' . $ajaxEnabledSteps . ')/i', $event->getStep()->getText())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,10 +150,10 @@ JS;
|
|||||||
*/
|
*/
|
||||||
public function handleAjaxAfterStep(StepEvent $event)
|
public function handleAjaxAfterStep(StepEvent $event)
|
||||||
{
|
{
|
||||||
$ajax_enabled_steps = $this->getMainContext()->getAjaxSteps();
|
$ajaxEnabledSteps = $this->getMainContext()->getAjaxSteps();
|
||||||
$ajax_enabled_steps = implode('|', array_filter($ajax_enabled_steps));
|
$ajaxEnabledSteps = implode('|', array_filter($ajaxEnabledSteps));
|
||||||
|
|
||||||
if (empty($ajax_enabled_steps) || !preg_match('/(' . $ajax_enabled_steps . ')/i', $event->getStep()->getText())) {
|
if (empty($ajaxEnabledSteps) || !preg_match('/(' . $ajaxEnabledSteps . ')/i', $event->getStep()->getText())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ JS;
|
|||||||
$parent = $event->getLogicalParent();
|
$parent = $event->getLogicalParent();
|
||||||
$feature = $parent->getFeature();
|
$feature = $parent->getFeature();
|
||||||
$step = $event->getStep();
|
$step = $event->getStep();
|
||||||
$screenshot_path = null;
|
$screenshotPath = null;
|
||||||
|
|
||||||
$path = $this->getMainContext()->getScreenshotPath();
|
$path = $this->getMainContext()->getScreenshotPath();
|
||||||
if(!$path) return; // quit silently when path is not set
|
if(!$path) return; // quit silently when path is not set
|
||||||
@ -267,10 +267,10 @@ JS;
|
|||||||
{
|
{
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
|
||||||
$button_element = $page->find('named', array('link_or_button', "'$button'"));
|
$buttonElement = $page->find('named', array('link_or_button', "'$button'"));
|
||||||
assertNotNull($button_element, sprintf('%s button not found', $button));
|
assertNotNull($buttonElement, sprintf('%s button not found', $button));
|
||||||
|
|
||||||
$button_element->click();
|
$buttonElement->click();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,10 +280,10 @@ JS;
|
|||||||
{
|
{
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
|
||||||
$parent_element = $page->find('css', $selector);
|
$parentElement = $page->find('css', $selector);
|
||||||
assertNotNull($parent_element, sprintf('"%s" element not found', $selector));
|
assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
|
||||||
|
|
||||||
$element = $parent_element->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
|
$element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
|
||||||
assertNotNull($element, sprintf('"%s" not found', $text));
|
assertNotNull($element, sprintf('"%s" not found', $text));
|
||||||
|
|
||||||
$element->click();
|
$element->click();
|
||||||
|
@ -25,7 +25,7 @@ use SilverStripe\BehatExtension\Context\SilverStripeAwareContextInterface;
|
|||||||
class SilverStripeAwareInitializer implements InitializerInterface
|
class SilverStripeAwareInitializer implements InitializerInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private $database_name;
|
private $databaseName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Array
|
* @var Array
|
||||||
@ -55,10 +55,10 @@ class SilverStripeAwareInitializer implements InitializerInterface
|
|||||||
/**
|
/**
|
||||||
* Initializes initializer.
|
* Initializes initializer.
|
||||||
*/
|
*/
|
||||||
public function __construct($framework_path, $framework_host)
|
public function __construct($frameworkPath, $frameworkHost)
|
||||||
{
|
{
|
||||||
$this->bootstrap($framework_path, $framework_host);
|
$this->bootstrap($frameworkPath, $frameworkHost);
|
||||||
$this->database_name = $this->initializeTempDb();
|
$this->databaseName = $this->initializeTempDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
@ -85,7 +85,7 @@ class SilverStripeAwareInitializer implements InitializerInterface
|
|||||||
*/
|
*/
|
||||||
public function initialize(ContextInterface $context)
|
public function initialize(ContextInterface $context)
|
||||||
{
|
{
|
||||||
$context->setDatabase($this->database_name);
|
$context->setDatabase($this->databaseName);
|
||||||
$context->setAjaxSteps($this->ajaxSteps);
|
$context->setAjaxSteps($this->ajaxSteps);
|
||||||
$context->setAjaxTimeout($this->ajaxTimeout);
|
$context->setAjaxTimeout($this->ajaxTimeout);
|
||||||
$context->setScreenshotPath($this->screenshotPath);
|
$context->setScreenshotPath($this->screenshotPath);
|
||||||
@ -143,17 +143,17 @@ class SilverStripeAwareInitializer implements InitializerInterface
|
|||||||
return $this->screenshotPath;
|
return $this->screenshotPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function bootstrap($framework_path, $framework_host)
|
protected function bootstrap($frameworkPath, $frameworkHost)
|
||||||
{
|
{
|
||||||
file_put_contents('php://stderr', 'Bootstrapping' . PHP_EOL);
|
file_put_contents('php://stderr', 'Bootstrapping' . PHP_EOL);
|
||||||
|
|
||||||
// Set file to URL mappings
|
// Set file to URL mappings
|
||||||
global $_FILE_TO_URL_MAPPING;
|
global $_FILE_TO_URL_MAPPING;
|
||||||
$_FILE_TO_URL_MAPPING[dirname($framework_path)] = $framework_host;
|
$_FILE_TO_URL_MAPPING[dirname($frameworkPath)] = $frameworkHost;
|
||||||
|
|
||||||
// Connect to database and build manifest
|
// Connect to database and build manifest
|
||||||
$_GET['flush'] = 1;
|
$_GET['flush'] = 1;
|
||||||
require_once $framework_path . '/core/Core.php';
|
require_once $frameworkPath . '/core/Core.php';
|
||||||
unset($_GET['flush']);
|
unset($_GET['flush']);
|
||||||
|
|
||||||
// Remove the error handler so that PHPUnit can add its own
|
// Remove the error handler so that PHPUnit can add its own
|
||||||
|
@ -54,14 +54,14 @@ class LoginContext extends BehatContext
|
|||||||
public function stepIAmLoggedIn()
|
public function stepIAmLoggedIn()
|
||||||
{
|
{
|
||||||
$c = $this->getMainContext();
|
$c = $this->getMainContext();
|
||||||
$admin_url = $c->joinUrlParts($c->getBaseUrl(), $c->getAdminUrl());
|
$adminUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getAdminUrl());
|
||||||
$login_url = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
|
$loginUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
|
||||||
|
|
||||||
$this->getSession()->visit($admin_url);
|
$this->getSession()->visit($adminUrl);
|
||||||
|
|
||||||
if (0 == strpos($this->getSession()->getCurrentUrl(), $login_url)) {
|
if (0 == strpos($this->getSession()->getCurrentUrl(), $loginUrl)) {
|
||||||
$this->stepILogInWith('admin', 'password');
|
$this->stepILogInWith('admin', 'password');
|
||||||
assertStringStartsWith($admin_url, $this->getSession()->getCurrentUrl());
|
assertStringStartsWith($adminUrl, $this->getSession()->getCurrentUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,17 +113,17 @@ class LoginContext extends BehatContext
|
|||||||
public function stepILogInWith($email, $password)
|
public function stepILogInWith($email, $password)
|
||||||
{
|
{
|
||||||
$c = $this->getMainContext();
|
$c = $this->getMainContext();
|
||||||
$login_url = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
|
$loginUrl = $c->joinUrlParts($c->getBaseUrl(), $c->getLoginUrl());
|
||||||
|
|
||||||
$this->getSession()->visit($login_url);
|
$this->getSession()->visit($loginUrl);
|
||||||
|
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
|
||||||
$email_field = $page->find('css', '[name=Email]');
|
$emailField = $page->find('css', '[name=Email]');
|
||||||
$password_field = $page->find('css', '[name=Password]');
|
$passwordField = $page->find('css', '[name=Password]');
|
||||||
$submit_button = $page->find('css', '[type=submit]');
|
$submit_button = $page->find('css', '[type=submit]');
|
||||||
$email_field->setValue($email);
|
$emailField->setValue($email);
|
||||||
$password_field->setValue($password);
|
$passwordField->setValue($password);
|
||||||
$submit_button->press();
|
$submit_button->press();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +134,8 @@ class LoginContext extends BehatContext
|
|||||||
{
|
{
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
|
||||||
$login_form = $page->find('css', '#MemberLoginForm_LoginForm');
|
$loginForm = $page->find('css', '#MemberLoginForm_LoginForm');
|
||||||
assertNotNull($login_form, 'I should see a log-in form');
|
assertNotNull($loginForm, 'I should see a log-in form');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,8 +145,8 @@ class LoginContext extends BehatContext
|
|||||||
{
|
{
|
||||||
$page = $this->getSession()->getPage();
|
$page = $this->getSession()->getPage();
|
||||||
|
|
||||||
$bad_message = $page->find('css', '.message.bad');
|
$badMessage = $page->find('css', '.message.bad');
|
||||||
|
|
||||||
assertNotNull($bad_message, 'Bad message not found.');
|
assertNotNull($badMessage, 'Bad message not found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,12 @@ interface SilverStripeAwareContextInterface
|
|||||||
*
|
*
|
||||||
* @param String $database_name Temp database name
|
* @param String $database_name Temp database name
|
||||||
*/
|
*/
|
||||||
public function setDatabase($database_name);
|
public function setDatabase($databaseName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks steps as AJAX steps for special treatment
|
* Marks steps as AJAX steps for special treatment
|
||||||
*
|
*
|
||||||
* @param array $ajax_steps Array of step name parts to match
|
* @param array $ajax_steps Array of step name parts to match
|
||||||
*/
|
*/
|
||||||
public function setAjaxSteps($ajax_steps);
|
public function setAjaxSteps($ajaxSteps);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ require_once 'vendor/autoload.php';
|
|||||||
*/
|
*/
|
||||||
class SilverStripeContext extends MinkContext implements SilverStripeAwareContextInterface
|
class SilverStripeContext extends MinkContext implements SilverStripeAwareContextInterface
|
||||||
{
|
{
|
||||||
protected $database_name;
|
protected $databaseName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Array Partial string match for step names
|
* @var Array Partial string match for step names
|
||||||
@ -60,9 +60,9 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
|
|
||||||
protected $context;
|
protected $context;
|
||||||
protected $fixtures;
|
protected $fixtures;
|
||||||
protected $fixtures_lazy;
|
protected $fixturesLazy;
|
||||||
protected $files_path;
|
protected $filesPath;
|
||||||
protected $created_files_paths;
|
protected $createdFilesPaths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes context.
|
* Initializes context.
|
||||||
@ -76,9 +76,9 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
$this->context = $parameters;
|
$this->context = $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDatabase($database_name)
|
public function setDatabase($databaseName)
|
||||||
{
|
{
|
||||||
$this->database_name = $database_name;
|
$this->databaseName = $databaseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAjaxSteps($ajaxSteps)
|
public function setAjaxSteps($ajaxSteps)
|
||||||
@ -131,13 +131,13 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
return $this->screenshotPath;
|
return $this->screenshotPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFixture($data_object)
|
public function getFixture($dataObject)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($data_object, $this->fixtures)) {
|
if (!array_key_exists($dataObject, $this->fixtures)) {
|
||||||
throw new \OutOfBoundsException(sprintf('Data object `%s` does not exist!', $data_object));
|
throw new \OutOfBoundsException(sprintf('Data object `%s` does not exist!', $dataObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->fixtures[$data_object];
|
return $this->fixtures[$dataObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFixtures()
|
public function getFixtures()
|
||||||
@ -150,13 +150,13 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
*/
|
*/
|
||||||
public function before(ScenarioEvent $event)
|
public function before(ScenarioEvent $event)
|
||||||
{
|
{
|
||||||
if (!isset($this->database_name)) {
|
if (!isset($this->databaseName)) {
|
||||||
throw new \LogicException('Context\'s $database_name has to be set when implementing SilverStripeAwareContextInterface.');
|
throw new \LogicException('Context\'s $databaseName has to be set when implementing SilverStripeAwareContextInterface.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$setdb_url = $this->joinUrlParts($this->getBaseUrl(), '/dev/tests/setdb');
|
$setdbUrl = $this->joinUrlParts($this->getBaseUrl(), '/dev/tests/setdb');
|
||||||
$setdb_url = sprintf('%s?database=%s', $setdb_url, $this->database_name);
|
$setdbUrl = sprintf('%s?database=%s', $setdbUrl, $this->databaseName);
|
||||||
$this->getSession()->visit($setdb_url);
|
$this->getSession()->visit($setdbUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,9 +188,9 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
*/
|
*/
|
||||||
public function afterResetAssets(ScenarioEvent $event)
|
public function afterResetAssets(ScenarioEvent $event)
|
||||||
{
|
{
|
||||||
if (is_array($this->created_files_paths)) {
|
if (is_array($this->createdFilesPaths)) {
|
||||||
$created_files = array_reverse($this->created_files_paths);
|
$createdFiles = array_reverse($this->createdFilesPaths);
|
||||||
foreach ($created_files as $path) {
|
foreach ($createdFiles as $path) {
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
\Filesystem::removeFolder($path);
|
\Filesystem::removeFolder($path);
|
||||||
} else {
|
} else {
|
||||||
@ -204,44 +204,44 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
/**
|
/**
|
||||||
* @Given /^there are the following ([^\s]*) records$/
|
* @Given /^there are the following ([^\s]*) records$/
|
||||||
*/
|
*/
|
||||||
public function thereAreTheFollowingRecords($data_object, PyStringNode $string)
|
public function thereAreTheFollowingRecords($dataObject, PyStringNode $string)
|
||||||
{
|
{
|
||||||
if (!is_array($this->fixtures)) {
|
if (!is_array($this->fixtures)) {
|
||||||
$this->fixtures = array();
|
$this->fixtures = array();
|
||||||
}
|
}
|
||||||
if (!is_array($this->fixtures_lazy)) {
|
if (!is_array($this->fixturesLazy)) {
|
||||||
$this->fixtures_lazy = array();
|
$this->fixturesLazy = array();
|
||||||
}
|
}
|
||||||
if (!isset($this->files_path)) {
|
if (!isset($this->filesPath)) {
|
||||||
$this->files_path = realpath($this->getMinkParameter('files_path'));
|
$this->filesPath = realpath($this->getMinkParameter('files_path'));
|
||||||
}
|
}
|
||||||
if (!is_array($this->created_files_paths)) {
|
if (!is_array($this->createdFilesPaths)) {
|
||||||
$this->created_files_paths = array();
|
$this->createdFilesPaths = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists($data_object, $this->fixtures)) {
|
if (array_key_exists($dataObject, $this->fixtures)) {
|
||||||
throw new \InvalidArgumentException(sprintf('Data object `%s` already exists!', $data_object));
|
throw new \InvalidArgumentException(sprintf('Data object `%s` already exists!', $dataObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
$fixture = array_merge(array($data_object . ':'), $string->getLines());
|
$fixture = array_merge(array($dataObject . ':'), $string->getLines());
|
||||||
$fixture = implode("\n ", $fixture);
|
$fixture = implode("\n ", $fixture);
|
||||||
|
|
||||||
if ('Folder' === $data_object) {
|
if ('Folder' === $dataObject) {
|
||||||
$this->prepareTestAssetsDirectories($fixture);
|
$this->prepareTestAssetsDirectories($fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('File' === $data_object) {
|
if ('File' === $dataObject) {
|
||||||
$this->prepareTestAssetsFiles($fixture);
|
$this->prepareTestAssetsFiles($fixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fixtures_lazy = array($data_object => array());
|
$fixturesLazy = array($dataObject => array());
|
||||||
if (preg_match('/=>(\w+)/', $fixture)) {
|
if (preg_match('/=>(\w+)/', $fixture)) {
|
||||||
$fixture_content = Yaml::parse($fixture);
|
$fixture_content = Yaml::parse($fixture);
|
||||||
foreach ($fixture_content[$data_object] as $identifier => &$fields) {
|
foreach ($fixture_content[$dataObject] as $identifier => &$fields) {
|
||||||
foreach ($fields as $field_val) {
|
foreach ($fields as $field_val) {
|
||||||
if (substr($field_val, 0, 2) == '=>') {
|
if (substr($field_val, 0, 2) == '=>') {
|
||||||
$fixtures_lazy[$data_object][$identifier] = $fixture_content[$data_object][$identifier];
|
$fixturesLazy[$dataObject][$identifier] = $fixture_content[$dataObject][$identifier];
|
||||||
unset($fixture_content[$data_object][$identifier]);
|
unset($fixture_content[$dataObject][$identifier]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,27 +250,27 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
|
|
||||||
// As we're dealing with split fixtures and can't join them, replace references by hand
|
// As we're dealing with split fixtures and can't join them, replace references by hand
|
||||||
// if (preg_match('/=>(\w+)\.([\w.]+)/', $fixture, $matches)) {
|
// if (preg_match('/=>(\w+)\.([\w.]+)/', $fixture, $matches)) {
|
||||||
// if ($matches[1] !== $data_object) {
|
// if ($matches[1] !== $dataObject) {
|
||||||
// $fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
// $fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
$fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
$fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
||||||
// Save fixtures into database
|
// Save fixtures into database
|
||||||
$this->fixtures[$data_object] = new \YamlFixture($fixture);
|
$this->fixtures[$dataObject] = new \YamlFixture($fixture);
|
||||||
$model = \DataModel::inst();
|
$model = \DataModel::inst();
|
||||||
$this->fixtures[$data_object]->saveIntoDatabase($model);
|
$this->fixtures[$dataObject]->saveIntoDatabase($model);
|
||||||
// Lazy load fixtures into database
|
// Lazy load fixtures into database
|
||||||
// Loop is required for nested lazy fixtures
|
// Loop is required for nested lazy fixtures
|
||||||
foreach ($fixtures_lazy[$data_object] as $identifier => $fields) {
|
foreach ($fixturesLazy[$dataObject] as $identifier => $fields) {
|
||||||
$fixture = array(
|
$fixture = array(
|
||||||
$data_object => array(
|
$dataObject => array(
|
||||||
$identifier => $fields,
|
$identifier => $fields,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$fixture = Yaml::dump($fixture);
|
$fixture = Yaml::dump($fixture);
|
||||||
$fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
$fixture = preg_replace_callback('/=>(\w+)\.([\w.]+)/', array($this, 'replaceFixtureReferences'), $fixture);
|
||||||
$this->fixtures_lazy[$data_object][$identifier] = new \YamlFixture($fixture);
|
$this->fixturesLazy[$dataObject][$identifier] = new \YamlFixture($fixture);
|
||||||
$this->fixtures_lazy[$data_object][$identifier]->saveIntoDatabase($model);
|
$this->fixturesLazy[$dataObject][$identifier]->saveIntoDatabase($model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,11 +286,11 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
|
|
||||||
$folder_path = ASSETS_PATH . DIRECTORY_SEPARATOR . $value;
|
$folder_path = ASSETS_PATH . DIRECTORY_SEPARATOR . $value;
|
||||||
if (file_exists($folder_path) && !is_dir($folder_path)) {
|
if (file_exists($folder_path) && !is_dir($folder_path)) {
|
||||||
throw new \Exception(sprintf('`%s` already exists and is not a directory', $this->files_path));
|
throw new \Exception(sprintf('`%s` already exists and is not a directory', $this->filesPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
\Filesystem::makeFolder($folder_path);
|
\Filesystem::makeFolder($folder_path);
|
||||||
$this->created_files_paths[] = $folder_path;
|
$this->createdFilesPaths[] = $folder_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,18 +306,18 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
$value = substr($value, strlen('assets/'));
|
$value = substr($value, strlen('assets/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_path = $this->files_path . DIRECTORY_SEPARATOR . basename($value);
|
$filePath = $this->filesPath . DIRECTORY_SEPARATOR . basename($value);
|
||||||
if (!file_exists($file_path) || !is_file($file_path)) {
|
if (!file_exists($filePath) || !is_file($filePath)) {
|
||||||
throw new \Exception(sprintf('`%s` does not exist or is not a file', $this->files_path));
|
throw new \Exception(sprintf('`%s` does not exist or is not a file', $this->filesPath));
|
||||||
}
|
}
|
||||||
$asset_path = ASSETS_PATH . DIRECTORY_SEPARATOR . $value;
|
$asset_path = ASSETS_PATH . DIRECTORY_SEPARATOR . $value;
|
||||||
if (file_exists($asset_path) && !is_file($asset_path)) {
|
if (file_exists($asset_path) && !is_file($asset_path)) {
|
||||||
throw new \Exception(sprintf('`%s` already exists and is not a file', $this->files_path));
|
throw new \Exception(sprintf('`%s` already exists and is not a file', $this->filesPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!file_exists($asset_path)) {
|
if (!file_exists($asset_path)) {
|
||||||
if (@copy($file_path, $asset_path)) {
|
if (@copy($filePath, $asset_path)) {
|
||||||
$this->created_files_paths[] = $asset_path;
|
$this->createdFilesPaths[] = $asset_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,17 +333,17 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
return $this->idFromFixture($references[1], $references[2]);
|
return $this->idFromFixture($references[1], $references[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function idFromFixture($class_name, $identifier)
|
protected function idFromFixture($className, $identifier)
|
||||||
{
|
{
|
||||||
if (false !== ($id = $this->fixtures[$class_name]->idFromFixture($class_name, $identifier))) {
|
if (false !== ($id = $this->fixtures[$className]->idFromFixture($className, $identifier))) {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
if (isset($this->fixtures_lazy[$class_name], $this->fixtures_lazy[$class_name][$identifier]) &&
|
if (isset($this->fixturesLazy[$className], $this->fixturesLazy[$className][$identifier]) &&
|
||||||
false !== ($id = $this->fixtures_lazy[$class_name][$identifier]->idFromFixture($class_name, $identifier))) {
|
false !== ($id = $this->fixturesLazy[$className][$identifier]->idFromFixture($className, $identifier))) {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \OutOfBoundsException(sprintf('`%s` identifier in Data object `%s` does not exist!', $identifier, $class_name));
|
throw new \OutOfBoundsException(sprintf('`%s` identifier in Data object `%s` does not exist!', $identifier, $className));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,10 +424,10 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
}
|
}
|
||||||
|
|
||||||
$parts = func_get_args();
|
$parts = func_get_args();
|
||||||
$trim_slashes = function(&$part) {
|
$trimSlashes = function(&$part) {
|
||||||
$part = trim($part, '/');
|
$part = trim($part, '/');
|
||||||
};
|
};
|
||||||
array_walk($parts, $trim_slashes);
|
array_walk($parts, $trimSlashes);
|
||||||
|
|
||||||
return implode('/', $parts);
|
return implode('/', $parts);
|
||||||
}
|
}
|
||||||
@ -468,8 +468,8 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
|
|||||||
throw new \Exception('Fixture reference should be in following format: =>ClassName.identifier');
|
throw new \Exception('Fixture reference should be in following format: =>ClassName.identifier');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($class_name, $identifier) = explode('.', $reference);
|
list($className, $identifier) = explode('.', $reference);
|
||||||
$id = $this->idFromFixture($class_name, $identifier);
|
$id = $this->idFromFixture($className, $identifier);
|
||||||
//$step = preg_replace('#=>(.+?) for "([^"]*)"#', '"'.$id.'" for "'.$field.'"', $step);
|
//$step = preg_replace('#=>(.+?) for "([^"]*)"#', '"'.$id.'" for "'.$field.'"', $step);
|
||||||
|
|
||||||
// below is not working, because Selenium can't interact with hidden inputs
|
// below is not working, because Selenium can't interact with hidden inputs
|
||||||
@ -493,8 +493,8 @@ JAVASCRIPT;
|
|||||||
throw new \Exception('Fixture reference should be in following format: =>ClassName.identifier');
|
throw new \Exception('Fixture reference should be in following format: =>ClassName.identifier');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($class_name, $identifier) = explode('.', $reference);
|
list($className, $identifier) = explode('.', $reference);
|
||||||
$id = $this->idFromFixture($class_name, $identifier);
|
$id = $this->idFromFixture($className, $identifier);
|
||||||
//$step = preg_replace('#"([^"]*)" with =>(.+)#', '"'.$field.'" with "'.$id.'"', $step);
|
//$step = preg_replace('#"([^"]*)" with =>(.+)#', '"'.$field.'" with "'.$id.'"', $step);
|
||||||
|
|
||||||
// below is not working, because Selenium can't interact with hidden inputs
|
// below is not working, because Selenium can't interact with hidden inputs
|
||||||
|
@ -40,9 +40,9 @@ class Extension implements ExtensionInterface
|
|||||||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/services'));
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/services'));
|
||||||
$loader->load('silverstripe.yml');
|
$loader->load('silverstripe.yml');
|
||||||
|
|
||||||
$behat_base_path = $container->getParameter('behat.paths.base');
|
$behatBasePath = $container->getParameter('behat.paths.base');
|
||||||
$config['framework_path'] = realpath(sprintf('%s%s%s',
|
$config['framework_path'] = realpath(sprintf('%s%s%s',
|
||||||
rtrim($behat_base_path, DIRECTORY_SEPARATOR),
|
rtrim($behatBasePath, DIRECTORY_SEPARATOR),
|
||||||
DIRECTORY_SEPARATOR,
|
DIRECTORY_SEPARATOR,
|
||||||
ltrim($config['framework_path'], DIRECTORY_SEPARATOR)
|
ltrim($config['framework_path'], DIRECTORY_SEPARATOR)
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user