示例#1
0
 /**
  * Tests the value of the last params in the closure in method filter.
  * Case of a scalar value.
  */
 public function testFilterWithScalarByKeyAndObjects()
 {
     $data = array('a', 'b');
     $objects = new resources\Foos($data);
     $result = $objects->filter(function ($value, $key, $objects) {
         return $objects[$key] === 'b';
     });
     $this->assertInstanceOf(get_class($objects), $result);
     $this->assertCount(1, $result);
     $this->assertSame($data[1], $result[1]);
 }
示例#2
0
 /**
  * Tests intersectK.
  */
 public function testIntersectK()
 {
     $data1 = array(1 => 'a', 0 => 'b', 'a' => 1, 'b' => 0);
     $data2 = array(1 => 'd', 2 => 'e', 'a' => 2, 'f' => 3);
     $data3 = array(1 => 'h', 3 => '1', 'a' => 4, 'g' => 5);
     $objects = new resources\Foos($data1);
     $result = $objects->intersectK(new Objects($data2), new Objects($data3));
     $this->assertInstanceOf(get_class($objects), $result);
     $this->assertSame(array_intersect_key($data1, $data2, $data3), $result->toArray());
 }
示例#3
0
 /**
  * Tests reverse when keys are not preserved.
  */
 public function testReverseWithoutPreservedKeys()
 {
     $data = array(1 => 'a', 0 => 'b', 'a' => 1, 'b' => 0);
     $objects = new resources\Foos($data);
     $result = $objects->reverse(false);
     $this->assertInstanceOf(get_class($objects), $result);
     $this->assertSame(array_reverse($data, false), $result->toArray());
 }