Skip to content

Commit

Permalink
Review feedback, Linting failures & tag for behat-extensions update
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed Oct 16, 2018
1 parent a927b8e commit 9f632d7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/Forms/ElementalAreaField.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace DNADesign\Elemental\Forms;

use BlocksPage;
use DNADesign\Elemental\Controllers\ElementalAreaController;
use DNADesign\Elemental\Models\BaseElement;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Services\ElementTabProvider;
use SilverStripe\Control\Controller;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\FieldGroup;
Expand Down Expand Up @@ -215,7 +215,7 @@ public function performReadonlyTransformation()
public function setSubmittedValue($value, $data = null)
{
// Content comes through as a JSON encoded list through a hidden field.
$this->setValue(Convert::json2array($value));
return $this->setValue(json_decode($value, true));
}

public function saveInto(DataObjectInterface $dataObject)
Expand All @@ -224,10 +224,11 @@ public function saveInto(DataObjectInterface $dataObject)
parent::saveInto($dataObject);

$elementData = $this->Value();
$idPrefixLength = strlen(sprintf(ElementalAreaController::FORM_NAME_TEMPLATE, ''));

foreach ($elementData as $form => $data) {
// Extract the ID
$elementId = (int) substr($form, 12);
$elementId = (int) substr($form, $idPrefixLength);

/** @var BaseElement $element */
$element = $this->getArea()->Elements()->byID($elementId);
Expand Down
10 changes: 6 additions & 4 deletions tests/Behat/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,12 @@ protected function findFieldInBlock($block, $name)
assertNotNull($label, sprintf('Could not find a label for a field with the content "%s"', $name));
assertCount(
1, $label, sprintf(
'Found more than one label containing the phrase "%s".',
$name
)
1,
$label,
sprintf(
'Found more than one label containing the phrase "%s".',
$name
)
);

$label = array_shift($label);
Expand Down
4 changes: 3 additions & 1 deletion tests/Behat/Context/FixtureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public function theHasAContentElementWithContent($type, $pageTitle, $elementTitl
}

$elementalArea = $page->ElementalArea();
$elementalArea->Elements()->add($this->getFixtureFactory()->createObject(ElementContent::class, $elementTitle));
$elementalArea->Elements()->add(
$this->getFixtureFactory()->createObject(ElementContent::class, $elementTitle)
);

// Create element
$element = $this->getFixtureFactory()->get(ElementContent::class, $elementTitle);
Expand Down
2 changes: 2 additions & 0 deletions tests/Behat/features/edit-block-element.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Feature: Edit elements in the CMS
Then I should see "Eve's Block"
But I should not see "Alice's Block"

# The "unsaved changes" dialog causes errors unless this is tagged with "@unsavedChanges"
@unsavedChanges
Scenario: I can preview a block and hide the form again
Given I see a list of blocks
Then I should see block 1
Expand Down

0 comments on commit 9f632d7

Please sign in to comment.