ScriptFUSION\Porter\Porter::setMapper PHP Method

setMapper() public method

public setMapper ( ScriptFUSION\Mapper\CollectionMapper $mapper )
$mapper ScriptFUSION\Mapper\CollectionMapper
    public function setMapper(CollectionMapper $mapper)
    {
        $this->mapper = $mapper;
        return $this;
    }

Usage Example

Example #1
0
 public function testMap()
 {
     $records = $this->porter->setMapper(\Mockery::mock(CollectionMapper::class)->shouldReceive('mapCollection')->with(\Mockery::type(\Iterator::class), $mapping = \Mockery::type(Mapping::class), \Mockery::any())->once()->andReturn(new \ArrayIterator($result = ['foo' => 'bar']))->getMock())->import($this->specification->setMapping(\Mockery::mock(Mapping::class)));
     self::assertInstanceOf(PorterRecords::class, $records);
     self::assertSame($result, iterator_to_array($records));
     /** @var MappedRecords $previous */
     self::assertInstanceOf(MappedRecords::class, $previous = $records->getPreviousCollection());
     self::assertNotSame($mapping, $previous->getMapping(), 'Mapping was not cloned.');
 }