/** * @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()); }
/** * @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)); }
/** * @test */ public function invalidKey() { $this->setExpectedException('RuntimeException'); Arr::extract(array('asd' => array('lksd' => array('mmfs9' => 87681))), null)->getOrThrow(new RuntimeException()); }
/** * @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; })); }
/** * @test * @return void */ public function testInvalidAttempt() { $this->setExpectedException('\\InvalidArgumentException'); Arr::applyOverride(array('a', 'b', 'c'), array('#[1=2]'), 'asd'); }