Пример #1
0
 /**
  * @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);
 }
Пример #2
0
 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);
 }
Пример #3
0
 /**
  * @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);
 }
Пример #4
0
 /**
  * @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);
 }
Пример #5
0
 /**
  * @dataProvider casesForWithout
  */
 public function testChainedWithout($collection, $without, $expected)
 {
     $container = new Container($collection);
     $actual = $container->without($without)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #6
0
 /**
  * @dataProvider casesForFind
  */
 public function testChainedFind($collection, $predicate, $expected)
 {
     $container = new Container($collection);
     $actual = $container->find($predicate)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #7
0
 /**
  * @dataProvider casesForToArray
  */
 public function testChainedToArray($collection, $expected)
 {
     $container = new Container($collection);
     $actual = $container->toArray()->value();
     $this->assertEquals($expected, $actual);
 }
Пример #8
0
 /**
  * @dataProvider casesForThru
  */
 public function testChainedThru($collection, $interceptor, $expected)
 {
     $container = new Container($collection);
     $actual = $container->thru($interceptor)->value();
     $this->assertSame($expected, $actual);
 }
Пример #9
0
 /**
  * @dataProvider casesForGet
  */
 public function testChainedGet($collection, $path, $expected)
 {
     $container = new Container($collection);
     $actual = $container->get($path, 'default')->value();
     $this->assertEquals($expected, $actual);
 }
Пример #10
0
 /**
  * @expectedException Exception
  * @expectedExceptionMessage No callable method found for "foo"
  */
 public function testInvalidChainMethod()
 {
     $container = new Container(array(1, 2, 3));
     $container->foo();
 }
Пример #11
0
 /**
  * @dataProvider casesForTakeRight
  */
 public function testChainedTakeRight($collection, $count, $fromEnd, $expected)
 {
     $container = new Container($collection);
     $actual = $container->takeRight($count, $fromEnd)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #12
0
 /**
  * @dataProvider casesForWhere
  */
 public function testChainedWhere($collection, $properties, $expected)
 {
     $container = new Container($collection);
     $actual = $container->where($properties)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #13
0
 /**
  * @dataProvider casesForIdentity
  */
 public function testChainedIdentity($value, $expected)
 {
     $container = new Container($value);
     $actual = $container->identity()->value();
     $this->assertSame($expected, $actual);
 }
Пример #14
0
 /**
  * @dataProvider casesForPluck
  */
 public function testChainedPluck($collection, $path, $expected)
 {
     $container = new Container($collection);
     $actual = $container->pluck($path)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #15
0
 /**
  * @dataProvider casesForAt
  */
 public function testChainedAt($collection, $index, $expected)
 {
     $container = new Container($collection);
     $actual = $container->at($index)->value();
     $this->assertEquals($expected, $actual);
 }
Пример #16
0
 /**
  * @dataProvider casesForEqual
  */
 public function testChainedEqual($a, $b, $expected)
 {
     $container = new Container($a);
     $actual = $container->equal($b)->value();
     $this->assertSame($expected, $actual);
 }