summaryrefslogtreecommitdiff
path: root/tests/php/include/valueiterator/1.php
diff options
context:
space:
mode:
authorvalmat <ufabiz@gmail.com>2014-03-18 15:18:11 +0600
committervalmat <ufabiz@gmail.com>2014-03-18 15:18:11 +0600
commite8334afd7f2920b706a3d28250a3e2b6dbd49538 (patch)
treea92e2b1b67c22eaad7eb84a2138ede2dae12e873 /tests/php/include/valueiterator/1.php
parentbfaed88493de0a3ebd7f2619cb11291cd09252b1 (diff)
Unit tests. For description see https://github.com/CopernicaMarketingSoftware/PHP-CPP/pull/25#issuecomment-37882236
Diffstat (limited to 'tests/php/include/valueiterator/1.php')
-rw-r--r--tests/php/include/valueiterator/1.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/php/include/valueiterator/1.php b/tests/php/include/valueiterator/1.php
new file mode 100644
index 0000000..984a77f
--- /dev/null
+++ b/tests/php/include/valueiterator/1.php
@@ -0,0 +1,76 @@
+<?php
+
+class SimpleClass {
+ public $cl0_float = 3.14;
+ public $cl0_str1 = 'public str1';
+ private $cl0_str2 = 'private str2';
+ protected $cl0_str3 = 'protected str3';
+}
+
+class impIterator implements Iterator {
+ private $position = 0;
+ private $array = array(
+ "firstElement",
+ "secondElement",
+ "lastelEment",
+ );
+
+ public function __construct() {
+ $this->position = 0;
+ }
+
+ function rewind() {
+ $this->position = 0;
+ }
+
+ function current() {
+ return $this->array[$this->position];
+ }
+
+ function key() {
+ return 'key_' . $this->position;
+ }
+
+ function next() {
+ ++$this->position;
+ }
+
+ function valid() {
+ return isset($this->array[$this->position]);
+ }
+
+ function __destruct() {
+ echo "~impIterator\n";
+ }
+}
+
+class impIterAggr1 implements IteratorAggregate {
+ public function getIterator() {
+ return new ArrayIterator(new SimpleClass);
+ }
+ function __destruct() {
+ echo "~impIterAggr1\n";
+ }
+}
+
+class impIterAggr2 implements IteratorAggregate {
+ public function getIterator() {
+ return new impIterator();
+ }
+ function __destruct() {
+ echo "~impIterAggr2\n";
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+