ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 30 of file ilCtrlArrayIteratorTest.php.

30  : void
31  {
32  $iterator = new ilCtrlArrayIterator([
33  'key0' => 'entry0',
34  'key1' => 'entry1',
35  'key2' => 'entry2',
36  ]);
37 
38  $expected_iterator_values = ['entry0', 'entry1', 'entry2'];
39  $expected_iterator_keys = ['key0', 'key1', 'key2'];
40 
41  for ($i = 0, $i_max = 3; $i < $i_max; $i++) {
42  $this->assertTrue($iterator->valid());
43  $this->assertEquals(
44  $expected_iterator_values[$i],
45  $iterator->current(),
46  );
47  $this->assertEquals(
48  $expected_iterator_keys[$i],
49  $iterator->key()
50  );
51 
52  $iterator->next();
53  }
54 
55  $this->assertFalse($iterator->valid());
56  }
Class ilCtrlArrayIterator.

◆ testArrayIteratorWithCommonStringArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithCommonStringArray ( )

Definition at line 58 of file ilCtrlArrayIteratorTest.php.

58  : void
59  {
60  $iterator = new ilCtrlArrayIterator([
61  'entry0',
62  'entry1',
63  'entry2',
64  ]);
65 
66  $this->assertFalse($iterator->valid());
67  $this->assertNull($iterator->current());
68  $this->assertNull($iterator->key());
69  }
Class ilCtrlArrayIterator.

◆ testArrayIteratorWithEmptyArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithEmptyArray ( )

Definition at line 95 of file ilCtrlArrayIteratorTest.php.

95  : void
96  {
97  $iterator = new ilCtrlArrayIterator([]);
98 
99  $this->assertFalse($iterator->valid());
100  $this->assertNull($iterator->current());
101  $this->assertNull($iterator->key());
102  }
Class ilCtrlArrayIterator.

◆ testArrayIteratorWithMixedArray()

ilCtrlArrayIteratorTest::testArrayIteratorWithMixedArray ( )

Definition at line 71 of file ilCtrlArrayIteratorTest.php.

71  : void
72  {
73  $iterator = new ilCtrlArrayIterator([
74  'key0' => 0,
75  1 => 'entry1',
76  2 => 2,
77  'key3' => 'entry3',
78  'key4' => false
79  ]);
80 
81  $this->assertTrue($iterator->valid());
82  $this->assertEquals(
83  'entry3',
84  $iterator->current()
85  );
86  $this->assertEquals(
87  'key3',
88  $iterator->key()
89  );
90 
91  $iterator->next();
92  $this->assertFalse($iterator->valid());
93  }
Class ilCtrlArrayIterator.

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