示例#1
0
 /**
  * @test
  * @return void
  */
 public function findsNot()
 {
     $found = Arr::find(array(1, 2, 3, 4), function ($item) use(&$processed) {
         return $item == 1234;
     });
     $this->assertFalse($found->exists());
 }
示例#2
0
 /**
  * @test
  */
 public function whenNoResultFoundReturnsANone()
 {
     $ary = range(1, 10);
     $filter = function ($n) {
         return $n > 30;
     };
     $result = Arr::filterSlice($ary, $filter);
     $expected = 'this-is-the-expected';
     $this->assertThat($result, $this->isInstanceOf('Ustream\\Option\\None'));
     $this->assertEquals($expected, $result->getOrElse($expected));
 }
示例#3
0
 /**
  * @test
  */
 public function invalidKey()
 {
     $this->setExpectedException('RuntimeException');
     Arr::extract(array('asd' => array('lksd' => array('mmfs9' => 87681))), null)->getOrThrow(new RuntimeException());
 }
示例#4
0
 /**
  * @test
  * @return void
  */
 public function mapValidToSome()
 {
     $this->assertEquals(new Some(array('2', '4', '6')), Arr::map(array(1, 2, 3), function ($item) {
         return (string) $item * 2;
     }));
 }
示例#5
0
 /**
  * @test
  * @return void
  */
 public function testInvalidAttempt()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     Arr::applyOverride(array('a', 'b', 'c'), array('#[1=2]'), 'asd');
 }