diff --git a/core/lib/Thelia/Action/Folder.php b/core/lib/Thelia/Action/Folder.php index 636b8eab7..a42330e47 100644 --- a/core/lib/Thelia/Action/Folder.php +++ b/core/lib/Thelia/Action/Folder.php @@ -97,6 +97,8 @@ class Folder extends BaseAction implements EventSubscriberInterface ->setVisible(!$folder->getVisible()) ->save(); + $event->setFolder($folder); + } public function updatePosition(UpdatePositionEvent $event) diff --git a/core/lib/Thelia/Tests/Action/FolderTest.php b/core/lib/Thelia/Tests/Action/FolderTest.php index cb925f148..a2c82700e 100644 --- a/core/lib/Thelia/Tests/Action/FolderTest.php +++ b/core/lib/Thelia/Tests/Action/FolderTest.php @@ -22,8 +22,10 @@ /*************************************************************************************/ namespace Thelia\Tests\Action; +use Propel\Runtime\ActiveQuery\Criteria; use Thelia\Action\Folder; use Thelia\Core\Event\Folder\FolderCreateEvent; +use Thelia\Core\Event\Folder\FolderDeleteEvent; use Thelia\Core\Event\Folder\FolderUpdateEvent; use Thelia\Model\FolderQuery; @@ -35,6 +37,10 @@ use Thelia\Model\FolderQuery; */ class FolderTest extends BaseAction { + /** + * test folder creation + * @covers Thelia\Action\Folder::create + */ public function testCreateFolder() { @@ -57,9 +63,15 @@ class FolderTest extends BaseAction $this->assertEquals(0, $folder->getParent()); } + /** + * test update creation + * @covers Thelia\Action\Folder::update + */ public function testUpdateFolder() { - $folder = FolderQuery::create()->findOne(); + $folder = FolderQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); if(null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); @@ -91,4 +103,29 @@ class FolderTest extends BaseAction $this->assertEquals(0, $updatedFolder->getParent()); $this->assertEquals($visible, $updatedFolder->getVisible()); } + + /** + * test folder removal + * @covers Thelia\Action\Folder::delete + */ + public function testDeleteFolder() + { + $folder = FolderQuery::create() + ->addAscendingOrderByColumn('RAND()') + ->findOne(); + + if(null === $folder) { + $this->fail('use fixtures before launching test, there is no folder in database'); + } + + $event = new FolderDeleteEvent($folder->getId()); + + $folderAction = new Folder($this->getContainer()); + $folderAction->delete($event); + + $deletedFolder = $event->getFolder(); + + $this->assertInstanceOf('Thelia\Model\Folder', $deletedFolder); + $this->assertTrue($deletedFolder->isDeleted()); + } } \ No newline at end of file diff --git a/core/lib/Thelia/Tests/Tools/FileManagerTest.php b/core/lib/Thelia/Tests/Tools/FileManagerTest.php index 7ea43bb85..1228867a7 100644 --- a/core/lib/Thelia/Tests/Tools/FileManagerTest.php +++ b/core/lib/Thelia/Tests/Tools/FileManagerTest.php @@ -7,7 +7,7 @@ * @author Guillaume MOREL */ -namespace Thelia\Tests\Type; +namespace Thelia\Tests\Tools; use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent; use Thelia\Core\Event\Image\ImageCreateOrUpdateEvent; @@ -19,7 +19,7 @@ use Thelia\Tools\FileManager; /** * Class FileManagerTest * - * @package Thelia\Tests\Type + * @package Thelia\Tests\Tools */ class FileManagerTest extends \PHPUnit_Framework_TestCase {