Exemplo n.º 1
0
 public function testMap()
 {
     $seq = new Sequence();
     $seq->add('a');
     $seq->add('b');
     $self = $this;
     $newSeq = $seq->map(function ($elem) use($self) {
         switch ($elem) {
             case 'a':
                 return 'c';
             case 'b':
                 return 'd';
             default:
                 $self->fail('Unexpected element: ' . var_export($elem, true));
         }
     });
     $this->assertInstanceOf('Collection\\Sequence', $newSeq);
     $this->assertNotSame($newSeq, $seq);
     $this->assertEquals(['c', 'd'], $newSeq->all());
 }