diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php old mode 100644 new mode 100755 diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php b/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php old mode 100644 new mode 100755 diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php new file mode 100755 index 000000000..e5a240b8b --- /dev/null +++ b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php @@ -0,0 +1,129 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Core\Template\Loop\Argument; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Type; +use Thelia\Type\TypeCollection; + +/** + * + * @author Etienne Roudeix + * + */ +class ArgumentTest extends \PHPUnit_Framework_TestCase +{ + function testArgumentCollectionConstruction() + { + $collection = new ArgumentCollection( + new Argument( + 'arg0', + new TypeCollection( + new Type\AnyType() + ) + ), + new Argument( + 'arg1', + new TypeCollection( + new Type\AnyType() + ) + ) + ); + + $collection->addArgument( + new Argument( + 'arg2', + new TypeCollection( + new Type\AnyType() + ) + ) + ); + + $this->assertAttributeEquals( + array( + 0 => new Argument( + 'arg0', + new TypeCollection( + new Type\AnyType() + ) + ), + 1 => new Argument( + 'arg1', + new TypeCollection( + new Type\AnyType() + ) + ), + 2 => new Argument( + 'arg2', + new TypeCollection( + new Type\AnyType() + ) + ), + ), + 'arguments', + $collection + ); + } + + function testArgumentCollectionFetch() + { + $collection = new ArgumentCollection( + new Argument( + 'arg0', + new TypeCollection( + new Type\AnyType() + ) + ), + new Argument( + 'arg1', + new TypeCollection( + new Type\AnyType() + ) + ), + new Argument( + 'arg2', + new TypeCollection( + new Type\AnyType() + ) + ) + ); + + + $arguments = \PHPUnit_Framework_Assert::readAttribute($collection, 'arguments'); + + $collection->rewind(); + while ($collection->valid()) { + + $argument = $collection->current(); + + $this->assertEquals( + $argument, + $arguments[$collection->key()] + ); + + $collection->next(); + } + } +} diff --git a/core/lib/Thelia/Tests/Type/TypeTest.php b/core/lib/Thelia/Tests/Type/TypeTest.php new file mode 100755 index 000000000..fa6e4ea31 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/TypeTest.php @@ -0,0 +1,82 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type; +use Thelia\Type\TypeCollection; + +/** + * + * @author Etienne Roudeix + * + */ +class TypeTest extends \PHPUnit_Framework_TestCase +{ + function testTypeCollectionConstruction() + { + $collection = new TypeCollection( + new Type\AnyType(), + new Type\AnyType() + ); + + $collection->addType( + new Type\AnyType() + ); + + $this->assertAttributeEquals( + array( + new Type\AnyType(), + new Type\AnyType(), + new Type\AnyType(), + ), + 'types', + $collection + ); + } + + function testTypeCollectionFetch() + { + $collection = new TypeCollection( + new Type\AnyType(), + new Type\AnyType(), + new Type\AnyType() + ); + + + $types = \PHPUnit_Framework_Assert::readAttribute($collection, 'types'); + + $collection->rewind(); + while ($collection->valid()) { + + $type = $collection->current(); + + $this->assertEquals( + $type, + $types[$collection->key()] + ); + + $collection->next(); + } + } +} diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php old mode 100644 new mode 100755 diff --git a/core/lib/Thelia/Type/TypeCollection.php b/core/lib/Thelia/Type/TypeCollection.php old mode 100644 new mode 100755 index 6ec10731b..621197776 --- a/core/lib/Thelia/Type/TypeCollection.php +++ b/core/lib/Thelia/Type/TypeCollection.php @@ -80,7 +80,7 @@ class TypeCollection implements \Iterator */ public function next() { - ++$this->types; + $this->position++; } /** @@ -91,7 +91,7 @@ class TypeCollection implements \Iterator */ public function key() { - return $this->types; + return $this->position; } /** diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php old mode 100644 new mode 100755