start testing folder crud
This commit is contained in:
@@ -22,9 +22,11 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
|
||||
use Thelia\Action\Address;
|
||||
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Model\Base\CustomerQuery;
|
||||
use Thelia\Tests\Action\BaseAction;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -34,20 +36,9 @@ use Thelia\Model\Base\CustomerQuery;
|
||||
* @package Thelia\Tests\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AddressTest extends \PHPUnit_Framework_TestCase
|
||||
class AddressTest extends BaseAction
|
||||
{
|
||||
|
||||
public function getContainer()
|
||||
{
|
||||
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
|
||||
|
||||
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
|
||||
$container->set("event_dispatcher", $dispatcher);
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
public function testCreatedAddress()
|
||||
{
|
||||
$customer = CustomerQuery::create()->findOne();
|
||||
|
||||
44
core/lib/Thelia/Tests/Action/BaseAction.php
Normal file
44
core/lib/Thelia/Tests/Action/BaseAction.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
|
||||
|
||||
/**
|
||||
* Class BaseAction
|
||||
* @package Thelia\Tests\Action\ImageTest
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseAction extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function getContainer()
|
||||
{
|
||||
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
|
||||
|
||||
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
|
||||
|
||||
$container->set("event_dispatcher", $dispatcher);
|
||||
|
||||
return $container;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action\DocumentTest;
|
||||
namespace Thelia\Tests\Action;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
94
core/lib/Thelia/Tests/Action/FolderTest.php
Normal file
94
core/lib/Thelia/Tests/Action/FolderTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action;
|
||||
use Thelia\Action\Folder;
|
||||
use Thelia\Core\Event\Folder\FolderCreateEvent;
|
||||
use Thelia\Core\Event\Folder\FolderUpdateEvent;
|
||||
use Thelia\Model\FolderQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderTest
|
||||
* @package Thelia\Tests\Action\ImageTest
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderTest extends BaseAction
|
||||
{
|
||||
public function testCreateFolder()
|
||||
{
|
||||
|
||||
$event = new FolderCreateEvent();
|
||||
$event
|
||||
->setParent(0)
|
||||
->setVisible(1)
|
||||
->setLocale('en_US')
|
||||
->setTitle('folder creation test');
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
|
||||
$folderAction->create($event);
|
||||
|
||||
$folder = $event->getFolder();
|
||||
|
||||
$this->assertInstanceOf('Thelia\Model\Folder', $folder);
|
||||
$this->assertEquals('folder creation test', $folder->getTitle());
|
||||
$this->assertEquals(1, $folder->getVisible());
|
||||
$this->assertEquals(0, $folder->getParent());
|
||||
}
|
||||
|
||||
public function testUpdateFolder()
|
||||
{
|
||||
$folder = FolderQuery::create()->findOne();
|
||||
|
||||
if(null === $folder) {
|
||||
$this->fail('use fixtures before launching test, there is no folder in database');
|
||||
}
|
||||
|
||||
$visible = !$folder->getVisible();
|
||||
$event = new FolderUpdateEvent($folder->getId());
|
||||
|
||||
$event
|
||||
->setLocale('en_US')
|
||||
->setTitle('test update folder')
|
||||
->setVisible($visible)
|
||||
->setChapo('test folder update chapo')
|
||||
->setDescription('update folder description')
|
||||
->setPostscriptum('update folder postscriptum')
|
||||
->setParent(0)
|
||||
;
|
||||
|
||||
$folderAction = new Folder($this->getContainer());
|
||||
$folderAction->update($event);
|
||||
|
||||
$updatedFolder = $event->getFolder();
|
||||
|
||||
$this->assertInstanceOf('Thelia\Model\Folder', $updatedFolder);
|
||||
$this->assertEquals('test update folder', $updatedFolder->getTitle());
|
||||
$this->assertEquals('test folder update chapo', $updatedFolder->getChapo());
|
||||
$this->assertEquals('update folder description', $updatedFolder->getDescription());
|
||||
$this->assertEquals('update folder postscriptum', $updatedFolder->getPostscriptum());
|
||||
$this->assertEquals(0, $updatedFolder->getParent());
|
||||
$this->assertEquals($visible, $updatedFolder->getVisible());
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\Action\ImageTest;
|
||||
namespace Thelia\Tests\Action;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
Reference in New Issue
Block a user