Add ContainerAwareTestCase and ExportHandlerTest

modifié:         core/lib/Thelia/ImportExport/Export/ExportHandler.php
	modifié:         core/lib/Thelia/ImportExport/Export/Type/ProductPricesExport.php
	nouveau fichier: core/lib/Thelia/Tests/ContainerAwareTestCase.php
	modifié:         core/lib/Thelia/Tests/Controller/ControllerTestBase.php
	nouveau fichier: core/lib/Thelia/Tests/ImportExport/Export/ExportHandlerTest.php
This commit is contained in:
Benjamin Perche
2014-07-25 10:19:52 +02:00
parent f61006912d
commit f891d8b788
5 changed files with 247 additions and 60 deletions

View File

@@ -11,72 +11,24 @@
/*************************************************************************************/
namespace Thelia\Tests\Controller;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Controller\Admin\ImportController;
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarArchiveBuilder;
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarBz2ArchiveBuilder;
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveBuilder;
use Thelia\Core\FileFormat\Archive\ArchiveBuilderManager;
use Thelia\Core\FileFormat\Formatting\Formatter\JsonFormatter;
use Thelia\Core\FileFormat\Formatting\Formatter\XMLFormatter;
use Thelia\Core\FileFormat\Formatting\FormatterManager;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Translation\Translator;
use Thelia\Log\Tlog;
use Thelia\Controller\BaseController;
use Thelia\Tests\ContainerAwareTestCase;
/**
* Class ControllerTestBase
* @package Thelia\Tests\ImportExport\Import
* @author Benjamin Perche <bperche@openstudio.fr>
*/
abstract class ControllerTestBase extends \PHPUnit_Framework_TestCase
abstract class ControllerTestBase extends ContainerAwareTestCase
{
protected $import;
/** @var ContainerInterface */
protected $container;
/** @var Session */
protected $session;
/** @var ImportController */
/** @var BaseController */
protected $controller;
public function getContainer()
{
$container = new \Symfony\Component\DependencyInjection\ContainerBuilder();
$container->set("thelia.translator", new Translator(new Container()));
$dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface");
$container->set("event_dispatcher", $dispatcher);
$request = new Request();
$request->setSession($this->session);
$container->set("request", $request);
$this->buildContainer($container);
return $container;
}
public function getSession()
{
return new Session();
}
public function setUp()
{
parent::setUp();
Tlog::getNewInstance();
$this->session = $this->getSession();
$this->container = $this->getContainer();
$this->controller = $this->getController();
$this->controller->setContainer($this->container);
@@ -87,9 +39,4 @@ abstract class ControllerTestBase extends \PHPUnit_Framework_TestCase
*/
abstract protected function getController();
/**
* Use this method to build the container with the services that you need.
*/
abstract protected function buildContainer(ContainerBuilder $container);
}