PhpBench\Tests\Unit\Storage\Driver\Xml\HistoryIteratorTest::testIterate PHP Method

testIterate() public method

It should iterate over entries.
public testIterate ( )
    public function testIterate()
    {
        $collections = [];
        $collections[1] = $this->createEntry(1, new \DateTime('2014-02-03'));
        $collections[2] = $this->createEntry(2, new \DateTime('2016-01-01'));
        $collections[3] = $this->createEntry(3, new \DateTime('2016-02-01'));
        $collections[4] = $this->createEntry(4, new \DateTime('2016-02-03'));
        $collections[5] = $this->createEntry(5, new \DateTime('2016-02-08 12:00:00'));
        $collections[6] = $this->createEntry(6, new \DateTime('2016-02-08 06:00:00'));
        $this->xmlDecoder->decode(Argument::type(Document::class))->will(function ($args) use(&$order, &$collections) {
            $dom = $args[0];
            $uuid = $dom->evaluate('number(./@uuid)');
            return $collections[$uuid];
        });
        $entries = iterator_to_array($this->iterator);
        $this->assertCount(6, $entries);
        $first = array_shift($entries);
        $this->assertEquals('2016-02-08 12:00:00', $first->getDate()->format('Y-m-d H:i:s'));
        $this->assertEquals(5, $first->getNbSubjects());
        $this->assertEquals(10, $first->getNbIterations());
        $this->assertEquals(1000, $first->getNbRevolutions());
        $this->assertEquals(1, $first->getMinTime());
        $this->assertEquals(2, $first->getMaxTime());
        $this->assertEquals(3, $first->getMeanTime());
        $this->assertEquals(4, $first->getMeanRelStDev());
        $this->assertEquals(5, $first->getTotalTime());
        $last = array_pop($entries);
        $this->assertEquals('2014-02-03', $last->getDate()->format('Y-m-d'));
    }