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

@@ -33,10 +33,11 @@
"simplepie/simplepie": "dev-master", "simplepie/simplepie": "dev-master",
"imagine/imagine": "0.*", "imagine/imagine": "0.*",
"symfony/icu": "1.0", "symfony/icu": "1.0",
"swiftmailer/swiftmailer": "5.0.*", "swiftmailer/swiftmailer": "5.2.*",
"symfony/serializer": "2.3.*", "symfony/serializer": "2.3.*",
"ensepar/html2pdf": "1.0.1", "ensepar/html2pdf": "1.0.1",
"symfony/finder": "~2.2" "symfony/finder": "~2.2",
"symfony/browser-kit": "2.3.*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "4.1.*", "phpunit/phpunit": "4.1.*",

133
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "73a6895063dd76bcb25eb14ef329e745", "hash": "4606e1d72b13b6b8fa84dca5f7bac16b",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
@@ -608,25 +608,28 @@
}, },
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v5.0.2", "version": "v5.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git", "url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379" "reference": "2b9af56cc676c338d52fca4c657e5bdff73bb7af"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/f3917ecef35a4e4d98b303eb9fee463bc983f379", "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/2b9af56cc676c338d52fca4c657e5bdff73bb7af",
"reference": "f3917ecef35a4e4d98b303eb9fee463bc983f379", "reference": "2b9af56cc676c338d52fca4c657e5bdff73bb7af",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.2.4" "php": ">=5.2.4"
}, },
"require-dev": {
"mockery/mockery": "~0.9.1"
},
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "5.1-dev" "dev-master": "5.2-dev"
} }
}, },
"autoload": { "autoload": {
@@ -641,7 +644,9 @@
"authors": [ "authors": [
{ {
"name": "Fabien Potencier", "name": "Fabien Potencier",
"email": "fabien@symfony.com" "email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
}, },
{ {
"name": "Chris Corbyn" "name": "Chris Corbyn"
@@ -653,7 +658,7 @@
"mail", "mail",
"mailer" "mailer"
], ],
"time": "2013-08-30 12:35:21" "time": "2014-06-13 11:44:54"
}, },
{ {
"name": "symfony-cmf/routing", "name": "symfony-cmf/routing",
@@ -704,6 +709,63 @@
], ],
"time": "2013-03-25 15:02:40" "time": "2013-03-25 15:02:40"
}, },
{
"name": "symfony/browser-kit",
"version": "v2.3.13",
"target-dir": "Symfony/Component/BrowserKit",
"source": {
"type": "git",
"url": "https://github.com/symfony/BrowserKit.git",
"reference": "97563874c24b65ea8d31b82fe051a161caf83e10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/97563874c24b65ea8d31b82fe051a161caf83e10",
"reference": "97563874c24b65ea8d31b82fe051a161caf83e10",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/dom-crawler": "~2.0"
},
"require-dev": {
"symfony/css-selector": "~2.0",
"symfony/process": "~2.0"
},
"suggest": {
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\BrowserKit\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony BrowserKit Component",
"homepage": "http://symfony.com",
"time": "2014-04-18 20:35:25"
},
{ {
"name": "symfony/class-loader", "name": "symfony/class-loader",
"version": "v2.2.6", "version": "v2.2.6",
@@ -903,6 +965,61 @@
"homepage": "http://symfony.com", "homepage": "http://symfony.com",
"time": "2013-07-21 09:38:59" "time": "2013-07-21 09:38:59"
}, },
{
"name": "symfony/dom-crawler",
"version": "v2.4.4",
"target-dir": "Symfony/Component/DomCrawler",
"source": {
"type": "git",
"url": "https://github.com/symfony/DomCrawler.git",
"reference": "e94b29c7cac964e58c406408d238ceeaa3604e78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/e94b29c7cac964e58c406408d238ceeaa3604e78",
"reference": "e94b29c7cac964e58c406408d238ceeaa3604e78",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/css-selector": "~2.0"
},
"suggest": {
"symfony/css-selector": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\DomCrawler\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony DomCrawler Component",
"homepage": "http://symfony.com",
"time": "2014-04-18 20:37:09"
},
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v2.2.6", "version": "v2.2.6",

View File

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

View File

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

View File

@@ -1165,7 +1165,7 @@
</route> </route>
<route id="export.customer.newsletter" path="/admin/export/customer/newsletter"> <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> </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\Form\Form;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router; use Symfony\Component\Routing\Router;
use Thelia\Condition\ConditionFactory; use Thelia\Condition\ConditionFactory;

View File

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

View File

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

View File

@@ -14,7 +14,6 @@ namespace Thelia\Core\Event\Coupon;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Condition\ConditionCollection; use Thelia\Condition\ConditionCollection;
use Thelia\Model\Coupon; use Thelia\Model\Coupon;
use Thelia\Model\Exception\InvalidArgumentException;
/** /**
* Occurring when a Coupon is created or updated * 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(); abstract protected function getArgDefinitions();
} }

View File

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

View File

@@ -152,9 +152,6 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
/** @var ConditionFactory $conditionFactory */ /** @var ConditionFactory $conditionFactory */
$conditionFactory = $this->container->get('thelia.condition.factory'); $conditionFactory = $this->container->get('thelia.condition.factory');
/** @var Request $request */
$request = $this->container->get('request');
/** @var MCoupon $coupon */ /** @var MCoupon $coupon */
foreach ($loopResult->getResultDataCollection() as $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; return $search;
} }
@@ -178,6 +175,7 @@ class Folder extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLo
->set("DESCRIPTION" , $folder->getVirtualColumn('i18n_DESCRIPTION')) ->set("DESCRIPTION" , $folder->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM" , $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSTSCRIPTUM" , $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("PARENT" , $folder->getParent()) ->set("PARENT" , $folder->getParent())
->set("ROOT" , $folder->getRoot($folder->getId()))
->set("URL" , $folder->getUrl($this->locale)) ->set("URL" , $folder->getUrl($this->locale))
->set("META_TITLE" , $folder->getVirtualColumn('i18n_META_TITLE')) ->set("META_TITLE" , $folder->getVirtualColumn('i18n_META_TITLE'))
->set("META_DESCRIPTION" , $folder->getVirtualColumn('i18n_META_DESCRIPTION')) ->set("META_DESCRIPTION" , $folder->getVirtualColumn('i18n_META_DESCRIPTION'))

View File

@@ -69,7 +69,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
new Argument( new Argument(
'order', 'order',
new TypeCollection( 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' 'manual'
), ),
@@ -133,10 +133,10 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
case "id_reverse": case "id_reverse":
$search->orderById(Criteria::DESC); $search->orderById(Criteria::DESC);
break; break;
case "alpha": case "title":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
break; break;
case "alpha_reverse": case "title_reverse":
$search->addDescendingOrderByColumn('i18n_TITLE'); $search->addDescendingOrderByColumn('i18n_TITLE');
break; break;
case "code": case "code":

View File

@@ -230,17 +230,10 @@ class FreeProduct extends AbstractRemoveOnProducts
$this->setRelatedCartItem($eligibleProduct, $cartEvent->getCartItem()->getId()); $this->setRelatedCartItem($eligibleProduct, $cartEvent->getCartItem()->getId());
$freeProductCartItem = $cartEvent->getCartItem(); $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) { if ($freeProductCartItem instanceof CartItem) {
$taxCountry = $this->facade->getDeliveryCountry();
// The discount is the product price. // The discount is the product price.
$discount = $freeProductCartItem->getPromo() ? $discount = $freeProductCartItem->getPromo() ?
$freeProductCartItem->getPromoPrice() : $freeProductCartItem->getPrice(); $freeProductCartItem->getPromoPrice() : $freeProductCartItem->getPrice();

View File

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

View File

@@ -60,6 +60,28 @@ class Category extends BaseCategory implements FileModelParentInterface
return $countProduct; 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 * 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 * Calculate next position relative to our parent
*/ */

View File

@@ -12,8 +12,11 @@
namespace Thelia\Tests\Action; namespace Thelia\Tests\Action;
use Propel\Runtime\Propel;
use Thelia\Action\Address; use Thelia\Action\Address;
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\AddressQuery;
use Thelia\Model\CustomerQuery; 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 * @file
* Functions needed for Thelia bootstrap * Functions needed for Thelia bootstrap
*/ */
ini_set('session.use_cookies', 0);
$env = "test"; $env = "test";
require_once __DIR__ . '/../../../bootstrap.php'; require_once __DIR__ . '/../../../bootstrap.php';

View File

@@ -1,17 +1,17 @@
{"1": { {"1": {
"_info": "area 1 : France", "_info": "area 1 : France",
"slices": { "slices": {
"0.25": "5.23", "0.25": 5.23,
"0.5": 5.8, "0.5": 5.99,
"0.75": 6.56, "0.75": 6.75,
"1": 7.13, "1": 7.36,
"2": 8.08, "2": 8.36,
"3": 9.22, "3": 9.55,
"5": 11.31, "5": 11.73,
"7": 13.4, "7": 13.92,
"10": 16.53, "10": 17.15,
"15": 19.14, "15": 19.81,
"30": 26.93 "30": 27.79
} }
}, "2": { }, "2": {
"_info": "area 2 : A Zone - Union Europ\u00e9enne et Suisse", "_info": "area 2 : A Zone - Union Europ\u00e9enne et Suisse",
@@ -34,87 +34,87 @@
}, "3": { }, "3": {
"_info": "area 3 : B Zone - Pays de l\u2019Europe de l\u2019Est (hors Union Europ\u00e9enne), Norv\u00e8ge, Maghreb", "_info": "area 3 : B Zone - Pays de l\u2019Europe de l\u2019Est (hors Union Europ\u00e9enne), Norv\u00e8ge, Maghreb",
"slices": { "slices": {
"1": 18.81, "1": 19.38,
"2": 20.62, "2": 22.23,
"3": 24.94, "3": 26.46,
"4": 29.26, "4": 30.69,
"5": 33.58, "5": 34.96,
"6": 37.91, "6": 39.24,
"7": 42.23, "7": 43.51,
"8": 46.55, "8": 47.79,
"9": 50.87, "9": 52.06,
"10": 55.2, "10": 56.34,
"15": 65.08, "15": 66.79,
"20": 74.96 "20": 77.24
} }
}, "4": { }, "4": {
"_info": "area 4 : C Zone - Pays d\u2019Afrique hors Maghreb, Canada, Etats-Unis, Proche et Moyen Orient", "_info": "area 4 : C Zone - Pays d\u2019Afrique hors Maghreb, Canada, Etats-Unis, Proche et Moyen Orient",
"slices": { "slices": {
"1": 22.04, "1": 23.66,
"2": 29.55, "2": 31.26,
"3": 38.86, "3": 40.47,
"4": 48.17, "4": 49.69,
"5": 57.48, "5": 58.90,
"6": 66.79, "6": 68.12,
"7": 76.1, "7": 77.33,
"8": 85.41, "8": 86.55,
"9": 94.72, "9": 95.76,
"10": 104.03, "10": 104.98,
"15": 126.92, "15": 129.87,
"20": 149.82 "20": 154.76
} }
}, "5": { }, "5": {
"_info": "area 5 : D Zone - Autres destinations", "_info": "area 5 : D Zone - Autres destinations",
"slices": { "slices": {
"1": 25.08, "1": 26.27,
"2": 37.72, "2": 38.81,
"3": 50.26, "3": 51.35,
"4": 62.8, "4": 63.89,
"5": 75.34, "5": 76.43,
"6": 87.88, "6": 88.97,
"7": 100.42, "7": 101.51,
"8": 112.96, "8": 114.05,
"9": 125.5, "9": 126.59,
"10": 138.04, "10": 139.13,
"15": 162.74, "15": 163.83,
"20": 187.44 "20": 188.53
} }
}, "6": { }, "6": {
"_info": "area 6 : France OM1", "_info": "area 6 : France OM1",
"slices": { "slices": {
"0.5": 8.27, "0.5": 8.5,
"1": 12.49, "1": 12.87,
"2": 17.05, "2": 17.58,
"3": 21.61, "3": 22.28,
"4": 26.17, "4": 26.98,
"5": 30.73, "5": 31.68,
"6": 35.29, "6": 36.39,
"7": 39.85, "7": 41.09,
"8": 44.41, "8": 45.79,
"9": 48.97, "9": 50.49,
"10": 53.53, "10": 55.2,
"15": 76.33, "15": 78.95,
"20": 99.13, "20": 102.7,
"25": 121.93, "25": 126.45,
"30": 144.73 "30": 150.2
} }
}, "7": { }, "7": {
"_info": "area 7 : France OM2", "_info": "area 7 : France OM2",
"slices": { "slices": {
"0.5": 9.88, "0.5": 10.17,
"1": 14.92, "1": 15.39,
"2": 26.32, "2": 27.12,
"3": 37.72, "3": 38.86,
"4": 49.12, "4": 50.59,
"5": 60.52, "5": 62.32,
"6": 71.92, "6": 74.05,
"7": 83.32, "7": 85.79,
"8": 94.72, "8": 97.52,
"9": 106.12, "9": 109.25,
"10": 117.52, "10": 120.98,
"15": 174.52, "15": 179.69,
"20": 231.52, "20": 238.4,
"25": 288.52, "25": 297.11,
"30": 345.52 "30": 355.82
} }
}} }}

View File

@@ -44,16 +44,70 @@ CREATE TABLE `order_version`
REFERENCES `order` (`id`) REFERENCES `order` (`id`)
ON DELETE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB CHARACTER SET='utf8'; ) ENGINE=InnoDB CHARACTER SET='utf8';
UPDATE `order` SET
`version` = 1,
`version_created_at` = NOW(),
`version_created_by` = 'Thelia'
WHERE `version` = 0;
INSERT INTO `order_version`(
`id`,
`ref`,
`customer_id`,
`invoice_order_address_id`,
`delivery_order_address_id`,
`invoice_date`,
`currency_id`,
`currency_rate`,
`transaction_ref`,
`delivery_ref`,
`invoice_ref`,
`discount`,
`postage`,
`payment_module_id`,
`delivery_module_id`,
`status_id`,
`lang_id`,
`created_at`,
`updated_at`,
`version`,
`version_created_at`,
`version_created_by`)
SELECT
`id`,
`ref`,
`customer_id`,
`invoice_order_address_id`,
`delivery_order_address_id`,
`invoice_date`,
`currency_id`,
`currency_rate`,
`transaction_ref`,
`delivery_ref`,
`invoice_ref`,
`discount`,
`postage`,
`payment_module_id`,
`delivery_module_id`,
`status_id`,
`lang_id`,
`created_at`,
`updated_at`,
`version`,
`version_created_at`,
`version_created_by`
FROM `order`;
# Add missing columns to coupon (version_created_at, version_created_by) # Add missing columns to coupon (version_created_at, version_created_by)
ALTER TABLE `coupon` ADD `version_created_at` DATE AFTER `version`; ALTER TABLE `coupon` ADD `version_created_at` DATE AFTER `version`;
ALTER TABLE `coupon` ADD `version_created_by` VARCHAR(100) AFTER `version_created_at`; ALTER TABLE `coupon` ADD `version_created_by` VARCHAR(100) AFTER `version_created_at`;
# Add Brand tables and related resources
# Add the "brand" resource # Add the "brand" resource
INSERT INTO resource (`code`, `created_at`, `updated_at`) VALUES ('admin.brand', NOW(), NOW()); INSERT INTO resource (`code`, `created_at`, `updated_at`) VALUES ('admin.brand', NOW(), NOW());
# Add Brand tables
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- brand -- brand
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------