1 | <?php |
||
18 | class ContainsCollectionTest extends UnitTestCase |
||
19 | { |
||
20 | public function testContainsReturnsTrueIfValueFoundInCollection() |
||
21 | { |
||
22 | $coll = Factory::create($this->fixtures['assoc']); |
||
23 | $this->assertTrue($coll->contains('first')); |
||
24 | $this->assertTrue($coll->contains('second')); |
||
25 | $this->assertTrue($coll->contains('third')); |
||
26 | $this->assertFalse($coll->contains('fourth')); |
||
27 | $this->assertFalse($coll->contains('foo')); |
||
28 | $coll->add('foo'); |
||
29 | $this->assertTrue($coll->contains('foo')); |
||
30 | |||
31 | $this->assertFalse($coll->contains(100)); |
||
32 | $coll->add(100); |
||
33 | $this->assertFalse( |
||
34 | $coll->contains('100'), |
||
35 | 'Collection::contains method uses strict type comparison so that 100 !== "100"' |
||
36 | ); |
||
37 | // @todo |
||
38 | // I think we should add a second argument to contains() that does an additional check against |
||
39 | // the index so taht you can check whether the collection contains a certain value at a certain index. |
||
40 | // I think we should also allow for $value argument to be a callable. When it is a callable, |
||
41 | // it should be used instead of in_array to determine whether the collection contains whatever... |
||
42 | $this->assertTrue($coll->contains(100)); |
||
43 | } |
||
44 | } |
||
45 |