public function testCanRedirectToCorrectClass()
 {
     $under = Underscore::contains(array(1, 2, 3), 3);
     $this->assertEquals(2, $under);
 }
function _contains($list, $value, $strict = false)
{
    return Underscore::contains($list, $value, $strict);
}
示例#3
0
 /**
  * @tags collections
  */
 public function testContains()
 {
     // it should work with array, objects and iterators
     $this->typeTolerant([1, 2, 3], 2, function ($in, $out) {
         $this->boolean(_::contains($in, $out))->isTrue();
     }, [0, -1]);
     // it should return false if the item is not present in the list
     $this->boolean(_::contains([1, 2, 3], 4))->isFalse();
     // it should be capable of strict equality
     $this->boolean(_::contains([1, 2, 3], "2", true))->isFalse();
     // it should return false if the list is empty
     $this->boolean(_::contains([], 2))->isFalse();
 }