4 require_once
'Services/Contact/BuddySystem/test/ilBuddySystemBaseTest.php';
33 $this->assertFalse($collection->isEmpty());
34 $this->assertSame($elements, $collection->toArray());
35 $this->assertSame(array_values($elements), $collection->getValues());
36 $this->assertSame(array_keys($elements), $collection->getKeys());
38 foreach($elements as $key => $elm)
40 $this->assertArrayHasKey($collection->getKey($elm), $elements);
41 $this->assertTrue(isset($collection[$key]));
42 $this->assertEquals($collection[$key], $elm);
53 $this->assertTrue($collection->isEmpty());
55 foreach($elements as $elm)
57 $collection->add($elm);
58 $this->assertTrue($collection->contains($elm));
61 foreach($elements as $elm)
63 $collection->removeElement($elm);
64 $this->assertFalse($collection->contains($elm));
67 $this->assertTrue($collection->isEmpty());
69 foreach($elements as $elm)
71 $collection->add($elm);
72 $this->assertTrue($collection->contains($elm));
75 foreach($elements as $elm)
77 $key = $collection->getKey($elm);
78 $collection->remove($key);
79 $this->assertFalse($collection->contains($elm));
82 $this->assertTrue($collection->isEmpty());
84 foreach($elements as $key => $elm)
86 $collection[$key] = $elm;
87 $this->assertTrue($collection->contains($elm));
90 foreach($elements as $key => $elm)
92 unset($collection[$key]);
93 $this->assertFalse($collection->contains($elm));
96 $this->assertTrue($collection->isEmpty());
100 $data = $collection->toArray();
101 $this->assertSame(5, reset(
$data));
112 foreach($collection->getIterator() as $key => $item)
114 $this->assertSame($elements[$key], $item,
"Item {$key} not match");
117 $this->assertCount($iterations, $elements,
"Number of iterations not match");
127 $collection->removeElement(5);
137 $collection->remove(
"phpunit");
151 $this->assertCount(2, $collection->filter(
function($elm) {
152 return $elm % 2 === 0;
167 $this->assertSame(
array(3), $collection->slice(2, 1)->getValues());
175 $relation_1 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
176 $relation_2 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
177 $relation_3 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
178 $relation_4 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
179 $relation_5 = $this->getMockBuilder(
'ilBuddySystemRelation')->disableOriginalConstructor()->getMock();
183 'associative' =>
array(
array(
'A' =>
'a',
'B' =>
'b',
'C' =>
'c')),
184 'mixed' =>
array(
array(0,
'A' =>
'a', 1,
'B' =>
'b', 2, 3)),
185 'relations' =>
array(
array($relation_1, $relation_2, $relation_3, $relation_4, $relation_5))
testRemovingAnNonExistingElementByKeyRaisesAnException()
InvalidArgumentException
testElementsCanBeAddedAndRemoved($elements)
provideElements
Class ilBuddySystemRelationCollectionTest.
assertException($exception_class)
Class ilBuddySystemRelationCollection A collection which contains all entries of a buddy list...
testElementsCanBeInitiallyAdded($elements)
provideElements
testElementsCanBeSliced()
Create styles array
The data for the language used.
testElementsCanBeFiltered()
testRemovingAnNonExistingElementRaisesAnException()
InvalidArgumentException
testIterator($elements)
provideElements