Ejemplo n.º 1
0
 public function testContains()
 {
     $object = array(1, 2, 3, 4, 5);
     $return = true;
     $result = __::contains($object, 4);
     $this->assertEquals($return, $result);
 }
Ejemplo n.º 2
0
 public function testInclud()
 {
     // from js
     $this->assertTrue(__::includ(array(1, 2, 3), 2), 'two is in the array');
     $this->assertFalse(__::includ(array(1, 3, 9), 2), 'two is not in the array');
     $this->assertTrue(__(array(1, 2, 3))->includ(2), 'OO-style includ');
     // extra
     $collection = array(true, false, 0, 1, -1, 'foo', array(), array('meh'));
     $this->assertTrue(__::includ($collection, true));
     $this->assertTrue(__::includ($collection, false));
     $this->assertTrue(__::includ($collection, 0));
     $this->assertTrue(__::includ($collection, 1));
     $this->assertTrue(__::includ($collection, -1));
     $this->assertTrue(__::includ($collection, 'foo'));
     $this->assertTrue(__::includ($collection, array()));
     $this->assertTrue(__::includ($collection, array('meh')));
     $this->assertFalse(__::includ($collection, 'true'));
     $this->assertFalse(__::includ($collection, '0'));
     $this->assertFalse(__::includ($collection, '1'));
     $this->assertFalse(__::includ($collection, '-1'));
     $this->assertFalse(__::includ($collection, 'bar'));
     $this->assertFalse(__::includ($collection, 'Foo'));
     $this->assertTrue(__::contains((object) array('moe' => 1, 'larry' => 3, 'curly' => 9), 3), '__::includ on objects checks their values');
     // docs
     $this->assertTrue(__::includ(array(1, 2, 3), 3));
 }