diff --git a/core/model/SQLMap.php b/core/model/SQLMap.php index bbd0a4348..583e04aa6 100755 --- a/core/model/SQLMap.php +++ b/core/model/SQLMap.php @@ -48,12 +48,9 @@ class SQLMap extends Object implements IteratorAggregate { } } - /* - * Iterator - necessary for foreach to work - */ public function getIterator() { $this->genItems(); - return $this->items->getIterator(); + return new SQLMap_Iterator($this->items->getIterator()); } /** @@ -87,4 +84,37 @@ class SQLMap extends Object implements IteratorAggregate { } } -?> +class SQLMap_Iterator extends Object implements Iterator { + protected $items; + + function __construct(Iterator $items) { + $this->items = $items; + } + + + /* + * Iterator functions - necessary for foreach to work + */ + public function rewind() { + return $this->items->rewind() ? $this->items->rewind()->Title : null; + } + + public function current() { + return $this->items->current()->Title; + } + + public function key() { + return $this->items->current()->ID; + } + + public function next() { + $next = $this->items->next(); + return isset($next->Title) ? $next->Title : null; + } + + public function valid() { + return $this->items->valid(); + } +} + +?> \ No newline at end of file diff --git a/tests/security/GroupTest.php b/tests/security/GroupTest.php new file mode 100644 index 000000000..df591e38c --- /dev/null +++ b/tests/security/GroupTest.php @@ -0,0 +1,25 @@ + $v) { + $mapOutput[$k] = $v; + } + + $group1 = $this->objFromFixture('Group', 'group1'); + $group2 = $this->objFromFixture('Group', 'group2'); + + /* We have added 2 groups to our fixture. They should both appear in $mapOutput. */ + $this->assertEquals($mapOutput[$group1->ID], $group1->Title); + $this->assertEquals($mapOutput[$group2->ID], $group2->Title); + } +} \ No newline at end of file diff --git a/tests/security/GroupTest.yml b/tests/security/GroupTest.yml new file mode 100644 index 000000000..9fa04d760 --- /dev/null +++ b/tests/security/GroupTest.yml @@ -0,0 +1,5 @@ +Group: + group1: + Title: Group 1 + group2: + Title: Group 2 \ No newline at end of file