MAJ en Thelia 2.3.4
@@ -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();
|
||||
|
||||
@@ -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
@@ -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
|
||||
*
|
||||
|
||||
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-1.png
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-2.png
Normal file → Executable file
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-3.png
Normal file → Executable file
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 6.4 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-4.png
Normal file → Executable file
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-5.png
Normal file → Executable file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-6.png
Normal file → Executable file
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-7.png
Normal file → Executable file
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-8.png
Normal file → Executable file
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
0
tests/phpunit/Thelia/Tests/Action/assets/images/sources/test-image-9.png
Normal file → Executable 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
3
tests/phpunit/Thelia/Tests/Command/CacheClearTest.php
Normal file → Executable 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);
|
||||
|
||||
|
||||
0
tests/phpunit/Thelia/Tests/Command/ModuleActivateCommandTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Command/ModuleDeactivateCommandTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Command/ModuleGenerateCommandTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Controller/DefaultControllerTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/HttpFoundation/RequestTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/HttpFoundation/Session/SessionTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Element/BaseLoopTestor.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AccessoryTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AddressTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AssociatedContentTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AttributeAvailabilityTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AttributeCombinationTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/AttributeTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/CategoryTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/ContentTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/CountryTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/CurrencyTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/CustomerTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/FeatureAvailabilityTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/FeatureTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/FeatureValueTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/FolderTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/ProductSaleElementTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/ProductTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Core/Template/Loop/TitleTest.php
Normal file → Executable 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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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
0
tests/phpunit/Thelia/Tests/Form/OrderDeliveryTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Log/TlogTest.php
Normal file → Executable file
@@ -28,6 +28,5 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
|
||||
$actualCurrency = Currency::getDefaultCurrency();
|
||||
|
||||
$this->assertEquals($expectedCurrency->getId(), $actualCurrency->getId());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
0
tests/phpunit/Thelia/Tests/Rewriting/RewritingResolverTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Rewriting/RewritingRetrieverTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/TaxEngine/CalculatorTest.php
Normal file → Executable 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
0
tests/phpunit/Thelia/Tests/Type/AlphaNumStringListTypeTest.php
Normal file → Executable file
0
tests/phpunit/Thelia/Tests/Type/AlphaNumStringTypeTest.php
Normal file → Executable 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()
|
||||
|
||||