24 protected function setUp()
26 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
29 protected function tearDown()
31 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
34 public function testCallChunked()
36 $values = array(1, 2, 3);
38 assertThat(ArrayOperation::callChunked(
function ($values)
40 return array(count($values));
41 }, $values, 2), is(array(2, 1)));
44 public function testCallChunkedWithNoValues()
48 assertThat(ArrayOperation::callChunked(
function ($values)
50 return array(count($values));
51 }, $values, 2), is(emptyArray()));
54 public function testCallChunkedWithValueSizeSmallerThanChunkLimit()
56 $values = array(1, 2, 3);
58 assertThat(ArrayOperation::callChunked(
function ($values)
60 return array(count($values));
61 }, $values, 5), is(array(3)));
64 public function testCallChunkedWithExactMultiple()
66 $values = array(1, 2, 3, 4);
68 assertThat(ArrayOperation::callChunked(
function ($values)
70 return array(count($values));
71 }, $values, 2), is(array(2, 2)));
79 ArrayOperation::callChunked(
function ($values)
81 return array(count($values));
85 public function testMultiSearch()
87 $haystack = array(100, 101, 102, 101);
88 assertThat(ArrayOperation::multiSearch(array(100),$haystack),is(0));
89 assertThat(ArrayOperation::multiSearch(array(101),$haystack),is(1));
90 assertThat(ArrayOperation::multiSearch(array(100,102),$haystack),is(0));
91 assertThat(ArrayOperation::multiSearch(array(200),$haystack),is(
false));
92 assertThat(ArrayOperation::multiSearch(array(200,102),$haystack),is(2));
testCallChunkedShouldThrowExceptionWhenChunkSizeIsNotPositive()