Merge branch 'master' into brands

Conflicts:
	core/lib/Thelia/Tools/FileManager.php
	setup/update/2.0.3.sql
This commit is contained in:
Franck Allimant
2014-06-26 16:35:08 +02:00
26 changed files with 535 additions and 144 deletions

View File

@@ -79,7 +79,7 @@ class Address extends BaseAction implements EventSubscriberInterface
->save()
;
if ($event->getIsDefault()) {
if ($event->getIsDefault() && !$addressModel->getIsDefault()) {
$addressModel->makeItDefault();
}

View File

@@ -127,10 +127,6 @@ class StartDate extends ConditionAbstract
*/
public function getSummary()
{
$i18nOperator = Operators::getI18n(
$this->translator, $this->operators[self::START_DATE]
);
$date = new \DateTime();
$date->setTimestamp($this->values[self::START_DATE]);
$strDate = $date->format($this->getDateFormat());

View File

@@ -1165,7 +1165,7 @@
</route>
<route id="export.customer.newsletter" path="/admin/export/customer/newsletter">
<default key="_controller">Thelia\Controller\Admin\CustomerExportController::NewsletterExportAction</default>
<default key="_controller">Thelia\Controller\Admin\CustomerExportController::newsletterExportAction</default>
</route>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<parameters>
<parameter key="test.client.class">Thelia\Core\HttpKernel\Client</parameter>
<parameter key="test.client.parameters" type="collection"></parameter>
<parameter key="test.client.history.class">Symfony\Component\BrowserKit\History</parameter>
<parameter key="test.client.cookiejar.class">Symfony\Component\BrowserKit\CookieJar</parameter>
</parameters>
<services>
<service id="test.client" class="%test.client.class%" scope="prototype">
<argument type="service" id="kernel" />
<argument>%test.client.parameters%</argument>
<argument type="service" id="test.client.history" />
<argument type="service" id="test.client.cookiejar" />
</service>
<service id="test.client.history" class="%test.client.history.class%" scope="prototype" />
<service id="test.client.cookiejar" class="%test.client.cookiejar.class%" scope="prototype" />
</services>
</config>

View File

@@ -14,7 +14,6 @@ namespace Thelia\Controller\Admin;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Condition\ConditionFactory;

View File

@@ -25,7 +25,7 @@ use Thelia\Model\NewsletterQuery;
class CustomerExportController extends BaseAdminController
{
public function NewsletterExportAction()
public function newsletterExportAction()
{
if (null !== $response = $this->checkAuth([AdminResources::EXPORT_CUSTOMER_NEWSLETTER], [], [AccessManager::VIEW])) {
return $response;

View File

@@ -181,13 +181,6 @@ class TranslationsController extends BaseAdminController
case 'ma' :
$template = new TemplateDefinition($item_name, TemplateDefinition::EMAIL);
break;
default:
/*
throw new \InvalidArgumentException(
$this->getTranslator()->trans("Undefined translation type: %item", ['%item' => $item_to_translate])
);
*/
}
if ($template) {

View File

@@ -14,7 +14,6 @@ namespace Thelia\Core\Event\Coupon;
use Thelia\Core\Event\ActionEvent;
use Thelia\Condition\ConditionCollection;
use Thelia\Model\Coupon;
use Thelia\Model\Exception\InvalidArgumentException;
/**
* Occurring when a Coupon is created or updated

View File

@@ -0,0 +1,43 @@
<?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\Core\HttpKernel;
use Symfony\Component\HttpKernel\Client as BaseClient;
use Thelia\Core\HttpFoundation\Request;
use Symfony\Component\BrowserKit\Request as DomRequest;
/**
* Class Client
* @package Thelia\Core\HttpKernel
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Client extends BaseClient
{
/**
* Converts the BrowserKit request to a HttpKernel request.
*
* @param DomRequest $request A Request instance
*
* @return Request A Request instance
*/
protected function filterRequest(DomRequest $request)
{
$httpRequest = Request::create($request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), $request->getFiles(), $request->getServer(), $request->getContent());
$httpRequest->files->replace($this->filterFiles($httpRequest->files->all()));
return $httpRequest;
}
}

View File

@@ -536,4 +536,4 @@ abstract class BaseLoop
*/
abstract protected function getArgDefinitions();
}
}

View File

@@ -190,9 +190,6 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface, Search
}
}
/* @todo */
$notEmpty = $this->getNot_empty();
return $search;
}
@@ -217,6 +214,7 @@ class Category extends BaseI18nLoop implements PropelSearchLoopInterface, Search
->set("DESCRIPTION" , $category->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("PARENT" , $category->getParent())
->set("ROOT" , $category->getRoot($category->getId()))
->set("URL" , $category->getUrl($this->locale))
->set("META_TITLE" , $category->getVirtualColumn('i18n_META_TITLE'))
->set("META_DESCRIPTION" , $category->getVirtualColumn('i18n_META_DESCRIPTION'))

View File

@@ -152,9 +152,6 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
/** @var ConditionFactory $conditionFactory */
$conditionFactory = $this->container->get('thelia.condition.factory');
/** @var Request $request */
$request = $this->container->get('request');
/** @var MCoupon $coupon */
foreach ($loopResult->getResultDataCollection() as $coupon) {

View File

@@ -157,9 +157,6 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLo
}
}
/* @todo */
$notEmpty = $this->getNot_empty();
return $search;
}
@@ -178,6 +175,7 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLo
->set("DESCRIPTION" , $folder->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("PARENT" , $folder->getParent())
->set("ROOT" , $folder->getRoot($folder->getId()))
->set("URL" , $folder->getUrl($this->locale))
->set("META_TITLE" , $folder->getVirtualColumn('i18n_META_TITLE'))
->set("META_DESCRIPTION" , $folder->getVirtualColumn('i18n_META_DESCRIPTION'))

View File

@@ -69,7 +69,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
new Argument(
'order',
new TypeCollection(
new Type\EnumListType(array('id', 'id_reverse', 'code', 'code_reverse', 'alpha', 'alpha_reverse', 'manual', 'manual_reverse', 'enabled', 'enabled_reverse'))
new Type\EnumListType(array('id', 'id_reverse', 'code', 'code_reverse', 'title', 'title_reverse', 'manual', 'manual_reverse', 'enabled', 'enabled_reverse'))
),
'manual'
),
@@ -133,10 +133,10 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
case "id_reverse":
$search->orderById(Criteria::DESC);
break;
case "alpha":
case "title":
$search->addAscendingOrderByColumn('i18n_TITLE');
break;
case "alpha_reverse":
case "title_reverse":
$search->addDescendingOrderByColumn('i18n_TITLE');
break;
case "code":

View File

@@ -230,17 +230,10 @@ class FreeProduct extends AbstractRemoveOnProducts
$this->setRelatedCartItem($eligibleProduct, $cartEvent->getCartItem()->getId());
$freeProductCartItem = $cartEvent->getCartItem();
// Setting product price is dangerous, as the customer could change the ordered quantity of this product.
// We will instead add the product price to the order discount.
// $cartEvent->getCartItem()->setPrice(0)->save();
}
}
if ($freeProductCartItem instanceof CartItem) {
$taxCountry = $this->facade->getDeliveryCountry();
// The discount is the product price.
$discount = $freeProductCartItem->getPromo() ?
$freeProductCartItem->getPromoPrice() : $freeProductCartItem->getPrice();

View File

@@ -11,6 +11,7 @@
/*************************************************************************************/
namespace Thelia\Coupon\Type;
use Thelia\Core\Translation\Translator;
/**
* A trait to manage a coupon which removes a percentage of cart items from the order total.

View File

@@ -78,7 +78,7 @@ class Tlog Implements LoggerInterface
protected $mode_back_office = false;
protected $level = self::MUET;
protected $prefixe = "";
protected $prefix = "";
protected $files = array();
protected $all_files = false;
protected $show_redirect = false;
@@ -194,9 +194,9 @@ class Tlog Implements LoggerInterface
return $this;
}
public function setPrefix($prefixe)
public function setPrefix($prefix)
{
$this->prefixe = $prefixe;
$this->prefix = $prefix;
return $this;
}
@@ -609,7 +609,7 @@ class Tlog Implements LoggerInterface
private function findOrigin()
{
$origine = array();
$origin = array();
if (function_exists('debug_backtrace')) {
@@ -624,8 +624,8 @@ class Tlog Implements LoggerInterface
$className = $hop['class'];
if (! empty($className) && ($className == ltrim(__CLASS__,'\\') || strtolower(get_parent_class($className)) == ltrim(__CLASS__,'\\'))) {
$origine['line'] = $hop['line'];
$origine['file'] = $hop['file'];
$origin['line'] = $hop['line'];
$origin['file'] = $hop['file'];
break;
}
}
@@ -633,7 +633,7 @@ class Tlog Implements LoggerInterface
$hop = array_pop($trace);
}
$origine['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
$origin['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
if(isset($prevHop['function']) &&
$prevHop['function'] !== 'include' &&
@@ -641,13 +641,13 @@ class Tlog Implements LoggerInterface
$prevHop['function'] !== 'require' &&
$prevHop['function'] !== 'require_once') {
$origine['function'] = $prevHop['function'];
$origin['function'] = $prevHop['function'];
} else {
$origine['function'] = 'main';
$origin['function'] = 'main';
}
}
return $origine;
return $origin;
}
protected function interpolate($message, array $context = array())
@@ -676,22 +676,22 @@ class Tlog Implements LoggerInterface
$text = $this->interpolate($text, $context);
$origine = $this->findOrigin();
$origin = $this->findOrigin();
$file = basename($origine['file']);
$file = basename($origin['file']);
if ($this->isActivedFile($file)) {
$function = $origine['function'];
$line = $origine['line'];
$function = $origin['function'];
$line = $origin['line'];
$prefixe = str_replace(
$prefix = str_replace(
array("#INDEX", "#LEVEL", "#FILE", "#FUNCTION", "#LINE", "#DATE", "#HOUR"),
array(1+$this->linecount, $level, $file, $function, $line, date("Y-m-d"), date("G:i:s")),
$this->prefixe
$this->prefix
);
$trace = $prefixe . $text;
$trace = $prefix . $text;
foreach ($this->destinations as $dest) {
$dest->add($trace);
@@ -706,7 +706,7 @@ class Tlog Implements LoggerInterface
* @param type $destinations
* @param array $actives array containing classes instanceof AbstractTlogDestination
*/
protected function loadDestinations(&$destinations, array $actives = NULL)
protected function loadDestinations(&$destinations, array $actives = null)
{
foreach ($actives as $active) {
if (class_exists($active)) {

View File

@@ -60,6 +60,28 @@ class Category extends BaseCategory implements FileModelParentInterface
return $countProduct;
}
/**
* Get the root category
* @param int $categoryId
* @return mixed
*/
public function getRoot($categoryId)
{
$category = CategoryQuery::create()->findPk($categoryId);
if(0 !== $category->getParent()) {
$parentCategory = CategoryQuery::create()->findPk($category->getParent());
if (null !== $parentCategory) {
$categoryId = $this->getRoot($parentCategory->getId());
}
}
return $categoryId;
}
/**
* Calculate next position relative to our parent
*/

View File

@@ -56,6 +56,28 @@ class Folder extends BaseFolder implements FileModelParentInterface
}
/**
* Get the root folder
* @param int $folderId
* @return mixed
*/
public function getRoot($folderId)
{
$folder = FolderQuery::create()->findPk($folderId);
if(0 !== $folder->getParent()) {
$parentFolder = FolderQuery::create()->findPk($folder->getParent());
if (null !== $parentFolder) {
$folderId = $this->getRoot($parentFolder->getId());
}
}
return $folderId;
}
/**
* Calculate next position relative to our parent
*/

View File

@@ -12,8 +12,11 @@
namespace Thelia\Tests\Action;
use Propel\Runtime\Propel;
use Thelia\Action\Address;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery;
/**
@@ -121,4 +124,71 @@ class AddressTest extends \PHPUnit_Framework_TestCase
}
/**
* Bug found in Thelia 2.0.2
*/
public function testUpdateDefaultAddress()
{
/**
* Disable propel cache in order to get a new instance of the
* active record in $updatedAddress
*/
Propel::disableInstancePooling();
/**
* Get a customer and it's default address
*/
$customer = CustomerQuery::create()->findOne();
$defaultAddress = $customer->getDefaultAddress();
$addressId = $defaultAddress->getId();
/**
* Try to update the address, and set the isDefault argument,
* that should keep this address as the default one.
*/
$addressEvent = new AddressCreateOrUpdateEvent(
"",
1,
"Thelia modif",
"Thelia modif",
"cour des étoiles",
"rue des miracles",
"",
"63000",
"clermont-ferrand",
64,
"0102030405",
"",
"",
1
);
$addressEvent->setAddress($defaultAddress);
$addressEvent->setDispatcher(
$this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface")
);
/**
* Do the update
*/
$actionAddress = new Address();
$actionAddress->update($addressEvent);
$updatedAddress = AddressQuery::create()
->findPk($addressId);
/**
* This address should still be the default address
*/
$this->assertEquals(
1,
$updatedAddress->getIsDefault()
);
/**
* Renable it after
*/
Propel::enableInstancePooling();
}
}

View File

@@ -0,0 +1,59 @@
<?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 Thelia\Core\Thelia;
/**
* Class WebTestCase
* @package Thelia\Tests
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class WebTestCase extends \PHPUnit_Framework_TestCase
{
/**
* @var \Thelia\Core\Thelia
*/
protected static $kernel;
/**
* @param array $options
* @param array $server
* @return \Symfony\Component\HttpKernel\Client
*/
protected static function createClient(array $options = [], array $server = [])
{
if (null !== static::$kernel) {
static::$kernel->shutdown();
}
static::$kernel = new Thelia('test', true);
static::$kernel->boot();
$client = static::$kernel->getContainer()->get('test.client');
$client->setServerParameters($server);
return $client;
}
/**
* Shuts the kernel down if it was used in the test.
*/
protected function tearDown()
{
if (null !== static::$kernel) {
static::$kernel->shutdown();
}
}
}

View File

@@ -5,6 +5,7 @@
* @file
* Functions needed for Thelia bootstrap
*/
ini_set('session.use_cookies', 0);
$env = "test";
require_once __DIR__ . '/../../../bootstrap.php';