Plum\Plum\WorkflowTest::processShouldApplyWriterToReadItemsIfFilterReturnsTrue PHP Метод

processShouldApplyWriterToReadItemsIfFilterReturnsTrue() публичный Метод

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