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
78 lines
2.6 KiB
PHP
78 lines
2.6 KiB
PHP
<?php
|
|
/*************************************************************************************/
|
|
/* This file is part of the Thelia package. */
|
|
/* */
|
|
/* Copyright (c) OpenStudio */
|
|
/* email : dev@thelia.net */
|
|
/* web : http://www.thelia.net */
|
|
/* */
|
|
/* For the full copyright and license information, please view the LICENSE.txt */
|
|
/* file that was distributed with this source code. */
|
|
/*************************************************************************************/
|
|
|
|
namespace Thelia\Tests;
|
|
use Symfony\Component\DependencyInjection\Container;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
use Thelia\Core\HttpFoundation\Request;
|
|
use Thelia\Core\HttpFoundation\Session\Session;
|
|
use Thelia\Core\Security\SecurityContext;
|
|
use Thelia\Core\Translation\Translator;
|
|
use Thelia\Log\Tlog;
|
|
|
|
/**
|
|
* Class ContainerAwareTestCase
|
|
* @package Thelia\Tests
|
|
* @author Benjamin Perche <bperche@openstudio.fr>
|
|
*/
|
|
abstract class ContainerAwareTestCase extends \PHPUnit_Framework_TestCase
|
|
{
|
|
protected $import;
|
|
|
|
/** @var ContainerInterface */
|
|
protected $container;
|
|
|
|
/** @var Session */
|
|
protected $session;
|
|
|
|
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);
|
|
|
|
$container->set("thelia.securitycontext", new SecurityContext($request));
|
|
|
|
$this->buildContainer($container);
|
|
|
|
return $container;
|
|
}
|
|
|
|
public function getSession()
|
|
{
|
|
return new Session();
|
|
}
|
|
|
|
public function setUp()
|
|
{
|
|
|
|
Tlog::getNewInstance();
|
|
|
|
$this->session = $this->getSession();
|
|
$this->container = $this->getContainer();
|
|
|
|
}
|
|
|
|
/**
|
|
* Use this method to build the container with the services that you need.
|
|
*/
|
|
abstract protected function buildContainer(ContainerBuilder $container);
|
|
}
|