/** * @dataProvider casesForUnion */ public function testChainedUnion($collections, $expected) { list($collection1, $collection2, $collection3) = $collections; $container = new Container($collection1); $actual = $container->union($collection2, $collection3)->value(); $this->assertEquals($expected, $actual); }
public function testNegateInChain() { $isPositive = function ($value) { return $value > 0; }; $container = new Container(array(2, -3, 5, -8)); $negatives = $container->filter(Functions\negate($isPositive))->values()->value(); $this->assertEquals(array(-3, -8), $negatives); }
/** * @dataProvider casesForMapValues */ public function testChainedMapValues($collection, $expected) { $self = $this; $iteratee = function ($value, $key, $collection2) use($self, $collection) { $self->assertSame($collection, $collection2); return $key . ' is ' . $value; }; $container = new Container($collection); $actual = $container->mapValues($iteratee)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForEach */ public function testChainedEach($collection, $expected) { $self = $this; $iterated = array(); $iteratee = function ($value, $key, $collection2) use($self, $collection, &$iterated) { $self->assertSame($collection, $collection2); $iterated[] = $key . ' is ' . $value; }; $container = new Container($collection); $container->each($iteratee)->value(); $this->assertEquals($expected, $iterated); }
/** * @dataProvider casesForWithout */ public function testChainedWithout($collection, $without, $expected) { $container = new Container($collection); $actual = $container->without($without)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForFind */ public function testChainedFind($collection, $predicate, $expected) { $container = new Container($collection); $actual = $container->find($predicate)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForToArray */ public function testChainedToArray($collection, $expected) { $container = new Container($collection); $actual = $container->toArray()->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForThru */ public function testChainedThru($collection, $interceptor, $expected) { $container = new Container($collection); $actual = $container->thru($interceptor)->value(); $this->assertSame($expected, $actual); }
/** * @dataProvider casesForGet */ public function testChainedGet($collection, $path, $expected) { $container = new Container($collection); $actual = $container->get($path, 'default')->value(); $this->assertEquals($expected, $actual); }
/** * @expectedException Exception * @expectedExceptionMessage No callable method found for "foo" */ public function testInvalidChainMethod() { $container = new Container(array(1, 2, 3)); $container->foo(); }
/** * @dataProvider casesForTakeRight */ public function testChainedTakeRight($collection, $count, $fromEnd, $expected) { $container = new Container($collection); $actual = $container->takeRight($count, $fromEnd)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForWhere */ public function testChainedWhere($collection, $properties, $expected) { $container = new Container($collection); $actual = $container->where($properties)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForIdentity */ public function testChainedIdentity($value, $expected) { $container = new Container($value); $actual = $container->identity()->value(); $this->assertSame($expected, $actual); }
/** * @dataProvider casesForPluck */ public function testChainedPluck($collection, $path, $expected) { $container = new Container($collection); $actual = $container->pluck($path)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForAt */ public function testChainedAt($collection, $index, $expected) { $container = new Container($collection); $actual = $container->at($index)->value(); $this->assertEquals($expected, $actual); }
/** * @dataProvider casesForEqual */ public function testChainedEqual($a, $b, $expected) { $container = new Container($a); $actual = $container->equal($b)->value(); $this->assertSame($expected, $actual); }