31 $this->assertFalse($collection->isEmpty());
32 $this->assertSame($elements, $collection->toArray());
33 $this->assertSame(array_values($elements), $collection->getValues());
34 $this->assertSame(array_keys($elements), $collection->getKeys());
36 foreach($elements as $key => $elm)
38 $this->assertArrayHasKey($collection->getKey($elm), $elements);
39 $this->assertTrue(isset($collection[$key]));
40 $this->assertEquals($collection[$key], $elm);
51 $this->assertTrue($collection->isEmpty());
53 foreach($elements as $elm)
55 $collection->add($elm);
56 $this->assertTrue($collection->contains($elm));
59 foreach($elements as $elm)
61 $collection->removeElement($elm);
62 $this->assertFalse($collection->contains($elm));
65 $this->assertTrue($collection->isEmpty());
67 foreach($elements as $elm)
69 $collection->add($elm);
70 $this->assertTrue($collection->contains($elm));
73 foreach($elements as $elm)
75 $key = $collection->getKey($elm);
76 $collection->remove($key);
77 $this->assertFalse($collection->contains($elm));
80 $this->assertTrue($collection->isEmpty());
82 foreach($elements as $key => $elm)
84 $collection[$key] = $elm;
85 $this->assertTrue($collection->contains($elm));
88 foreach($elements as $key => $elm)
90 unset($collection[$key]);
91 $this->assertFalse($collection->contains($elm));
94 $this->assertTrue($collection->isEmpty());
98 $data = $collection->toArray();
99 $this->assertSame(5, reset(
$data));
110 foreach($collection->getIterator() as $key => $item)
112 $this->assertSame($elements[$key], $item,
"Item {$key} not match");
115 $this->assertCount($iterations, $elements,
"Number of iterations not match");
124 $collection->removeElement(5);
133 $collection->remove(
"phpunit");
147 $this->assertCount(2, $collection->filter(
function($elm) {
148 return $elm % 2 === 0;
163 $this->assertSame(array(3), $collection->slice(2, 1)->getValues());
171 $relation_1 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
172 $relation_2 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
173 $relation_3 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
174 $relation_4 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
175 $relation_5 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
178 'indexed' => array(array(0, 1, 2, 3, 4, 5)),
179 'associative' => array(array(
'A' =>
'a',
'B' =>
'b',
'C' =>
'c')),
180 'mixed' => array(array(0,
'A' =>
'a', 1,
'B' =>
'b', 2, 3)),
181 'relations' => array(array($relation_1, $relation_2, $relation_3, $relation_4, $relation_5))
testRemovingAnNonExistingElementByKeyRaisesAnException()
InvalidArgumentException
testElementsCanBeAddedAndRemoved($elements)
provideElements
Class ilBuddySystemRelationCollectionTest.
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
testElementsCanBeInitiallyAdded($elements)
provideElements
testElementsCanBeSliced()
testElementsCanBeFiltered()
testRemovingAnNonExistingElementRaisesAnException()
InvalidArgumentException
testIterator($elements)
provideElements