ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlArrayIteratorTest Class Reference

Class ilCtrlArrayIteratorTest. More...

+ Inheritance diagram for ilCtrlArrayIteratorTest:
+ Collaboration diagram for ilCtrlArrayIteratorTest:

Public Member Functions

 testArrayIteratorWithAssociativeStringArray ()
 
 testArrayIteratorWithCommonStringArray ()
 
 testArrayIteratorWithMixedArray ()
 
 testArrayIteratorWithEmptyArray ()
 

Detailed Description

Member Function Documentation

◆ testArrayIteratorWithAssociativeStringArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithAssociativeStringArray ( )

Definition at line 16 of file ilCtrlArrayIteratorTest.php.

References $i.

16  : void
17  {
18  $iterator = new ilCtrlArrayIterator([
19  'key0' => 'entry0',
20  'key1' => 'entry1',
21  'key2' => 'entry2',
22  ]);
23 
24  $expected_iterator_values = ['entry0', 'entry1', 'entry2'];
25  $expected_iterator_keys = ['key0', 'key1', 'key2'];
26 
27  for ($i = 0, $i_max = 3; $i < $i_max; $i++) {
28  $this->assertTrue($iterator->valid());
29  $this->assertEquals(
30  $expected_iterator_values[$i],
31  $iterator->current(),
32  );
33  $this->assertEquals(
34  $expected_iterator_keys[$i],
35  $iterator->key()
36  );
37 
38  $iterator->next();
39  }
40 
41  $this->assertFalse($iterator->valid());
42  }
Class ilCtrlArrayIterator.
$i
Definition: metadata.php:41

◆ testArrayIteratorWithCommonStringArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithCommonStringArray ( )

Definition at line 44 of file ilCtrlArrayIteratorTest.php.

44  : void
45  {
46  $iterator = new ilCtrlArrayIterator([
47  'entry0',
48  'entry1',
49  'entry2',
50  ]);
51 
52  $this->assertFalse($iterator->valid());
53  $this->assertNull($iterator->current());
54  $this->assertNull($iterator->key());
55  }
Class ilCtrlArrayIterator.

◆ testArrayIteratorWithEmptyArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithEmptyArray ( )

Definition at line 81 of file ilCtrlArrayIteratorTest.php.

81  : void
82  {
83  $iterator = new ilCtrlArrayIterator([]);
84 
85  $this->assertFalse($iterator->valid());
86  $this->assertNull($iterator->current());
87  $this->assertNull($iterator->key());
88  }
Class ilCtrlArrayIterator.

◆ testArrayIteratorWithMixedArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithMixedArray ( )

Definition at line 57 of file ilCtrlArrayIteratorTest.php.

57  : void
58  {
59  $iterator = new ilCtrlArrayIterator([
60  'key0' => 0,
61  1 => 'entry1',
62  2 => 2,
63  'key3' => 'entry3',
64  'key4' => false
65  ]);
66 
67  $this->assertTrue($iterator->valid());
68  $this->assertEquals(
69  'entry3',
70  $iterator->current()
71  );
72  $this->assertEquals(
73  'key3',
74  $iterator->key()
75  );
76 
77  $iterator->next();
78  $this->assertFalse($iterator->valid());
79  }
Class ilCtrlArrayIterator.

The documentation for this class was generated from the following file: