diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index cca90b2b2..8560aa00e 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -113,6 +113,8 @@ class Content extends BaseAction implements EventSubscriberInterface ->setVisible(!$content->getVisible()) ->save(); + $event->setContent($content); + } public function delete(ContentDeleteEvent $event) diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php index 69a7d42c0..95ede1997 100644 --- a/core/lib/Thelia/Tests/Action/ContentTest.php +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -25,6 +25,7 @@ namespace Thelia\Tests\Action; use Thelia\Action\Content; use Thelia\Core\Event\Content\ContentCreateEvent; use Thelia\Core\Event\Content\ContentDeleteEvent; +use Thelia\Core\Event\Content\ContentToggleVisibilityEvent; use Thelia\Core\Event\Content\ContentUpdateEvent; use Thelia\Model\ContentQuery; use Thelia\Model\FolderQuery; @@ -107,6 +108,23 @@ class ContentTest extends BaseAction } + public function testContentToggleVisibility() + { + $content = $this->getRandomContent(); + + $visibility = $content->getVisible(); + + $event = new ContentToggleVisibilityEvent($content); + + $contentAction = new Content($this->getContainer()); + $contentAction->toggleVisibility($event); + + $updatedContent = $event->getContent(); + + $this->assertInstanceOf('Thelia\Model\Content', $updatedContent); + $this->assertEquals(!$visibility, $updatedContent->getVisible()); + } + /** * @return \Thelia\Model\Content */