Skip to content

Commit

Permalink
Merge pull request #1040 from Victoire/fix/widget-map-persist-rebase
Browse files Browse the repository at this point in the history
Fix test assertion was true with beginning condition
  • Loading branch information
paulandrieux authored Jan 31, 2018
2 parents 7874536 + 9198225 commit f2489cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Bundle/WidgetBundle/Model/WidgetManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,12 @@ public function deleteWidget(Widget $widget, View $view)
$this->entityManager->remove($widget);
}

//we update the view
$this->entityManager->persist($view);
//update the view deleting the widget
$this->widgetMapManager->delete($view, $widget);

//we update the view
$this->entityManager->persist($view);

$this->entityManager->flush();
}

Expand Down
5 changes: 5 additions & 0 deletions Bundle/WidgetMapBundle/Entity/WidgetMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ class WidgetMap
*/
protected $slot;

public function __toString()
{
return (string) $this->id;
}

public function __construct()
{
$this->children = new ArrayCollection();
Expand Down
4 changes: 3 additions & 1 deletion Bundle/WidgetMapBundle/Manager/WidgetMapManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ public function delete(View $view, Widget $widget)

//Move children WidgetMap for children from other View
foreach ($widgetMap->getChildren() as $child) {
$this->moveWidgetMap($child->getView(), $child, $originalParent, $originalPosition);
if ($child->getView() === $view || $child->getView()->getTemplate() === $view) {
$this->moveWidgetMap($child->getView(), $child, $originalParent, $originalPosition);
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions Tests/Features/WidgetMap/widgetMapTemplate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ Feature: Test widgetMap
Then I should see "Widget 1"
When I switch to "edit" mode
And I edit the "Text" widget
Then I should see "DELETE"
Then I should see "Widget 1"
And I should see "DELETE"
Given I follow "DELETE"
Then I should see "This action will permanently delete this content from the database. This action is irreversible."
Given I press "YES, I WANT TO DELETE IT!"
And I reload the page
And "Widget 3" should precede "Widget 2"
And I should not see "Widget 1"
Then I am on "/en/victoire-dcms/template/show/1"
And "Widget 1" should precede "Widget 3"
And "Widget 3" should precede "Widget 2"
Expand Down Expand Up @@ -353,6 +355,7 @@ Feature: Test widgetMap
And I should not see "Widget 4"
When I switch to "edit" mode
And I press the "Widget 2" content
And I wait 5 second
Then I should see "DELETE"
When I follow "DELETE"
Then I should see "This action will permanently delete this content from the database. This action is irreversible."
Expand All @@ -366,4 +369,4 @@ Feature: Test widgetMap
Then I should see "Widget 1"
And I should not see "Widget 2"
And I should see "Widget 3"
And I should see "Widget 4"
And I should see "Widget 4"

0 comments on commit f2489cc

Please sign in to comment.