예제 #1
0
 public function testZip()
 {
     // from js
     $names = array('moe', 'larry', 'curly');
     $ages = array(30, 40, 50);
     $leaders = array(true);
     $stooges = array(array('moe', 30, true), array('larry', 40, null), array('curly', 50, null));
     $this->assertEquals($stooges, __::zip($names, $ages, $leaders), 'zipped together arrays of different lengths');
     // extra
     $this->assertEquals($stooges, __($names)->zip($ages, $leaders), 'can perform OO-style zips of different length arrays');
     $numbers = array(1, 2, 3);
     $letters = array('a', 'b', 'c');
     $expected = array(array(1, 'a'), array(2, 'b'), array(3, 'c'));
     $this->assertEquals($expected, __::zip($numbers, $letters), 'can perform normal zips');
     $this->assertEquals($expected, __($numbers)->zip($letters), 'can perform OO-style zips');
     // docs
     $names = array('moe', 'larry', 'curly');
     $ages = array(30, 40, 50);
     $leaders = array(true, false, false);
     $expected = array(array('moe', 30, true), array('larry', 40, false), array('curly', 50, false));
     $result = __::zip($names, $ages, $leaders);
     $this->assertEquals($expected, $result);
 }
예제 #2
0
파일: __Test.php 프로젝트: robbinhan/PEASY
 public function testZip()
 {
     $object = array(array('a', 'b'), array(10, 20), array(true, false));
     $return = array(array('a', 10, true), array('b', 20, false));
     $result = __::zip($object[0], $object[1], $object[2]);
     $this->assertEquals($return, $result);
 }