diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 0acb903d3..52e1ce9b5 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -93,7 +93,7 @@ class Product extends BaseLoop new Argument( 'feature_available', new TypeCollection( - new Type\IntToCombinedIntsList(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new')) + new Type\IntToCombinedIntsListType(array('alpha', 'alpha_reverse', 'reverse', 'min_price', 'max_price', 'manual', 'manual_reverse', 'ref', 'promo', 'new')) ) ) ); diff --git a/core/lib/Thelia/Tests/Type/IntToCombinedIntsListTypeTest.php b/core/lib/Thelia/Tests/Type/IntToCombinedIntsListTypeTest.php new file mode 100755 index 000000000..9db5c96fd --- /dev/null +++ b/core/lib/Thelia/Tests/Type/IntToCombinedIntsListTypeTest.php @@ -0,0 +1,64 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\IntToCombinedIntsListType; + +/** + * + * @author Etienne Roudeix + * + */ +class IntToCombinedIntsListTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testIntToCombinedIntsListType() + { + $type = new IntToCombinedIntsListType(); + $this->assertTrue($type->isValid('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)')); + $this->assertFalse($type->isValid('1,2,3')); + } + + public function testFormatJsonType() + { + $type = new IntToCombinedIntsListType(); + $this->assertEquals( + $type->getFormattedValue('1: 2 & 5 | (6 &7), 4: *, 67: (1 & 9)'), + array( + 1 => array( + "values" => array(2,5,6,7), + "expression" => '2&5|(6&7)', + ), + 4 => array( + "values" => array('*'), + "expression" => '*', + ), + 67 => array( + "values" => array(1,9), + "expression" => '(1&9)', + ), + ) + ); + $this->assertNull($type->getFormattedValue('foo')); + } +} diff --git a/core/lib/Thelia/Type/IntToCombinedIntsList.php b/core/lib/Thelia/Type/IntToCombinedIntsListType.php similarity index 98% rename from core/lib/Thelia/Type/IntToCombinedIntsList.php rename to core/lib/Thelia/Type/IntToCombinedIntsListType.php index c9103c335..d4e9ec561 100755 --- a/core/lib/Thelia/Type/IntToCombinedIntsList.php +++ b/core/lib/Thelia/Type/IntToCombinedIntsListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntToCombinedIntsList implements TypeInterface +class IntToCombinedIntsListType implements TypeInterface { public function getType() {