|
|
@@ -683,7 +683,7 @@ class CollectionTest extends TestCase
|
|
|
{
|
|
|
$collection = new Collection($items);
|
|
|
$callback = function ($e) {
|
|
|
- return $e['a']['b']['c'] * - 1;
|
|
|
+ return $e['a']['b']['c'] * -1;
|
|
|
};
|
|
|
$this->assertEquals(['a' => ['b' => ['c' => 4]]], $collection->max($callback));
|
|
|
}
|
|
|
@@ -698,7 +698,7 @@ class CollectionTest extends TestCase
|
|
|
{
|
|
|
$collection = new Collection($items);
|
|
|
$this->assertEquals(['a' => ['b' => ['c' => 4]]], $collection->max(function ($e) {
|
|
|
- return $e['a']['b']['c'] * - 1;
|
|
|
+ return $e['a']['b']['c'] * -1;
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
@@ -1346,6 +1346,25 @@ class CollectionTest extends TestCase
|
|
|
$this->assertEquals(['a' => 4, 'b' => 5, 'c' => 6], $buffered->toArray());
|
|
|
}
|
|
|
|
|
|
+ public function testBufferedIterator()
|
|
|
+ {
|
|
|
+ $data = [
|
|
|
+ ['myField' => '1'],
|
|
|
+ ['myField' => '2'],
|
|
|
+ ['myField' => '3'],
|
|
|
+ ];
|
|
|
+ $buffered = (new \Cake\Collection\Collection($data))->buffered();
|
|
|
+ // Check going forwards
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '1']));
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '2']));
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '3']));
|
|
|
+
|
|
|
+ // And backwards.
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '3']));
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '2']));
|
|
|
+ $this->assertNotEmpty($buffered->firstMatch(['myField' => '1']));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Tests the combine method
|
|
|
*
|