MAJ en Thelia 2.3.4

This commit is contained in:
2020-05-03 08:14:07 +02:00
parent 72ddf49e60
commit 35a800ca0e
328 changed files with 9560 additions and 14163 deletions

View File

@@ -12,6 +12,7 @@
namespace Thelia\Tests\Action;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Filesystem\Filesystem;
use Thelia\Action\Cache;
use Thelia\Core\Event\Cache\CacheEvent;
@@ -37,7 +38,8 @@ class CacheTest extends \PHPUnit_Framework_TestCase
{
$event = new CacheEvent($this->dir);
$action = new Cache();
$adapter = new ArrayAdapter();
$action = new Cache($adapter);
$action->cacheClear($event);
$fs = new Filesystem();

View File

@@ -26,7 +26,7 @@ use Thelia\Model\Folder as FolderModel;
/**
* Class FolderTest
* @package Thelia\Tests\Action\ImageTest
* @package Thelia\Tests\Action
* @author Manuel Raynaud <manu@raynaud.io>
*/
class FolderTest extends TestCaseWithURLToolSetup

0
tests/phpunit/Thelia/Tests/Action/ImageTest.php Normal file → Executable file
View File

View File

@@ -622,6 +622,29 @@ class OrderTest extends BaseAction
);
}
/**
* @depends testCreate
*
* @param OrderModel $order
*/
public function testUpdateTransactionRef(OrderModel $order)
{
$transactionRef = uniqid('TRANSREF');
$this->orderEvent->setTransactionRef($transactionRef);
$this->orderEvent->setOrder($order);
$this->orderAction->updateTransactionRef($this->orderEvent);
$this->assertEquals(
$transactionRef,
$this->orderEvent->getOrder()->getTransactionRef()
);
$this->assertEquals(
$transactionRef,
OrderQuery::create()->findPk($order->getId())->getTransactionRef()
);
}
/**
* @depends testCreate
*

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

0
tests/phpunit/Thelia/Tests/Command/BaseCommandTest.php Normal file → Executable file
View File

3
tests/phpunit/Thelia/Tests/Command/CacheClearTest.php Normal file → Executable file
View File

@@ -12,6 +12,7 @@
namespace Thelia\Tests\Command;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\EventDispatcher;
@@ -101,7 +102,7 @@ class CacheClearTest extends ContainerAwareTestCase
protected function buildContainer(ContainerBuilder $container)
{
$eventDispatcher = new EventDispatcher();
$eventDispatcher->addSubscriber(new Cache());
$eventDispatcher->addSubscriber(new Cache(new ArrayAdapter()));
$container->set("event_dispatcher", $eventDispatcher);

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -468,6 +468,87 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
$this->assertEquals($expected, $actual);
}
/**
* @covers Thelia\Coupon\CouponManager::incrementQuantity
*/
public function testIncrementeQuantity()
{
$stubFacade = $this->generateFacadeStub();
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
$coupon->set(
$stubFacade,
'XMAS',
'',
'',
'',
array('amount' => 21.00),
true,
true,
true,
true,
254,
$date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection(),
false
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR,
MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::CART_TOTAL => 40.00,
MatchForTotalAmount::CART_CURRENCY => 'EUR'
);
$condition1->setValidatorsFromForm($operators, $values);
$condition2 = new MatchForTotalAmount($stubFacade);
$operators = array(
MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR,
MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::CART_TOTAL => 400.00,
MatchForTotalAmount::CART_CURRENCY => 'EUR'
);
$condition2->setValidatorsFromForm($operators, $values);
$conditions = new ConditionCollection();
$conditions[] = $condition1;
$conditions[] = $condition2;
$coupon->setConditions($conditions);
$stubFacade->expects($this->any())
->method('getCurrentCoupons')
->will($this->returnValue(array($coupon)));
$stubContainer->expects($this->any())
->method('get')
->will($this->onConsecutiveCalls($stubFacade));
$couponManager = new CouponManager($stubContainer);
$stubModel = $this->getMockBuilder('\Thelia\Model\Coupon')
->disableOriginalConstructor()
->getMock();
$stubModel->expects($this->any())
->method('getUsagesLeft')
->will($this->returnValue(21));
$stubModel->expects($this->any())
->method('setMaxUsage')
->will($this->returnValue(true));
$actual = $couponManager->incrementQuantity($stubModel, null);
$expected = 22;
$this->assertEquals($expected, $actual);
}
/**
* @covers Thelia\Coupon\CouponManager::decrementQuantity
*/
@@ -538,13 +619,100 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua
->getMock();
$stubModel->expects($this->any())
->method('getMaxUsage')
->will($this->returnValue(-1));
->willReturn(-1);
$stubModel->expects($this->any())
->method('isUsageUnlimited')
->willReturn(true);
$stubModel->expects($this->any())
->method('setMaxUsage')
->will($this->returnValue(true));
$actual = $couponManager->decrementQuantity($stubModel, null);
$expected = false;
$expected = true;
$this->assertEquals($expected, $actual);
}
/**
* @covers Thelia\Coupon\CouponManager::incrementQuantity
*/
public function testIncrementQuantityIllimited()
{
$stubFacade = $this->generateFacadeStub();
$stubContainer = $this->getMock('\Symfony\Component\DependencyInjection\Container');
$coupon = new RemoveXAmount($stubFacade);
$date = new \DateTime();
$coupon->set(
$stubFacade,
'XMAS',
'',
'',
'',
array('amount' => 21.00),
true,
true,
true,
true,
254,
$date->setTimestamp(strtotime("today + 3 months")),
new ObjectCollection(),
new ObjectCollection(),
false
);
$condition1 = new MatchForTotalAmount($stubFacade);
$operators = array(
MatchForTotalAmount::CART_TOTAL => Operators::SUPERIOR,
MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::CART_TOTAL => 40.00,
MatchForTotalAmount::CART_CURRENCY => 'EUR'
);
$condition1->setValidatorsFromForm($operators, $values);
$condition2 = new MatchForTotalAmount($stubFacade);
$operators = array(
MatchForTotalAmount::CART_TOTAL => Operators::INFERIOR,
MatchForTotalAmount::CART_CURRENCY => Operators::EQUAL
);
$values = array(
MatchForTotalAmount::CART_TOTAL => 400.00,
MatchForTotalAmount::CART_CURRENCY => 'EUR'
);
$condition2->setValidatorsFromForm($operators, $values);
$conditions = new ConditionCollection();
$conditions[] = $condition1;
$conditions[] = $condition2;
$coupon->setConditions($conditions);
$stubFacade->expects($this->any())
->method('getCurrentCoupons')
->will($this->returnValue(array($coupon)));
$stubContainer->expects($this->any())
->method('get')
->will($this->onConsecutiveCalls($stubFacade));
$couponManager = new CouponManager($stubContainer);
$stubModel = $this->getMockBuilder('\Thelia\Model\Coupon')
->disableOriginalConstructor()
->getMock();
$stubModel->expects($this->any())
->method('getMaxUsage')
-> willReturn(-1);
$stubModel->expects($this->any())
->method('isUsageUnlimited')
->willReturn(true);
$stubModel->expects($this->any())
->method('setMaxUsage')
->will($this->returnValue(true));
$actual = $couponManager->incrementQuantity($stubModel, null);
$expected = true;
$this->assertEquals($expected, $actual);
}

View File

@@ -63,6 +63,10 @@ class RemoveXAmountTest extends \PHPUnit_Framework_TestCase
->method('getCartTotalPrice')
->will($this->returnValue($cartTotalPrice));
$stubFacade->expects($this->any())
->method('getCartTotalTaxPrice')
->will($this->returnValue($cartTotalPrice));
$stubFacade->expects($this->any())
->method('getCheckoutCurrency')
->will($this->returnValue($checkoutCurrency));

View File

@@ -176,6 +176,9 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase
$file = $this->fileManager->copyUploadedFile($model, $uploadedFile);
// Normalize path
$file = str_replace('/', DS, $file);
$this->assertEquals("".$file, $targetFile);
$this->assertEquals(basename($targetFile), $model->getFile());
@@ -213,6 +216,9 @@ class FileManagerTest extends \PHPUnit_Framework_TestCase
$file = $this->fileManager->copyUploadedFile($model, $uploadedFile);
// Normalize path
$file = str_replace('/', DS, $file);
$this->assertEquals("".$file, $targetFile);
$this->assertEquals(basename($targetFile), $model->getFile());

0
tests/phpunit/Thelia/Tests/Form/CartAddTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Form/OrderDeliveryTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Log/TlogTest.php Normal file → Executable file
View File

View File

@@ -28,6 +28,5 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
$actualCurrency = Currency::getDefaultCurrency();
$this->assertEquals($expectedCurrency->getId(), $actualCurrency->getId());
}
}

View File

View File

View File

View File

@@ -56,9 +56,14 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
{
$this->downloader->download("https://github.com/foo/bar/baz", "baz");
}
public function testFileDownloadSuccess()
{
$this->downloader->download("http://thelia.net/", "php://temp");
$this->downloader->download("https://github.com/", "php://temp");
}
public function testFileDownloadSuccessWithRedirect()
{
$this->downloader->download("https://github.com/", "php://temp");
}
}

0
tests/phpunit/Thelia/Tests/Tools/URLTest.php Normal file → Executable file
View File

View File

View File

View File

@@ -37,7 +37,6 @@ class AnyListTypeTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_array($anyListFormat));
$this->assertCount(3, $anyListFormat);
$this->assertEquals($anyListFormat[1], 'string_2');
}
public function testEmptyAnyListType()

0
tests/phpunit/Thelia/Tests/Type/AnyTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/BooleanTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/EnumListTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/EnumTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/FloatTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/IntListTypeTest.php Normal file → Executable file
View File

View File

View File

0
tests/phpunit/Thelia/Tests/Type/IntTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/JsonTypeTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/Type/TypeCollectionTest.php Normal file → Executable file
View File

0
tests/phpunit/Thelia/Tests/bootstrap.php Normal file → Executable file
View File