public function processShouldApplyFilterToReadItems()
{
$iterator = m::mock('\\Iterator');
$iterator->shouldReceive('rewind');
$iterator->shouldReceive('valid')->andReturn(true)->twice();
$iterator->shouldReceive('current')->andReturn('foobar')->once();
$iterator->shouldReceive('next')->twice();
$iterator->shouldReceive('current')->andReturn('foo')->once();
$iterator->shouldReceive('valid')->andReturn(false)->once();
$reader = $this->getMockReader();
$reader->shouldReceive('getIterator')->andReturn($iterator);
$filter = $this->getMockFilter();
$filter->shouldReceive('filter')->with('foobar')->once()->andReturn(false);
$filter->shouldReceive('filter')->with('foo')->once()->andReturn(true);
$this->workflow->addFilter($filter);
$writer = $this->getMockWriter();
$writer->shouldReceive('prepare');
$writer->shouldReceive('finish');
$writer->shouldReceive('writeItem')->with('foo')->once();
$this->workflow->addWriter($writer);
$result = $this->workflow->process($reader);
$this->assertEquals(2, $result->getReadCount());
$this->assertEquals(1, $result->getWriteCount());
}