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

@@ -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';