PhpBench\Extensions\Dbal\Tests\Functional\Storage\Driver\Dbal\LoaderTest::testLoader PHP Method

testLoader() public method

The loader should load the collection from an Dbal database.
public testLoader ( )
    public function testLoader()
    {
        $suiteCollection = new SuiteCollection([TestUtil::createSuite(['uuid' => '1', 'subjects' => ['benchOne', 'benchTwo'], 'benchmarks' => ['BenchOne', 'BenchTwo'], 'groups' => ['one', 'two'], 'output_time_unit' => 'milliseconds', 'output_time_precision' => 7, 'output_mode' => 'throughput', 'revs' => 5, 'warmup' => 2, 'sleep' => 9, 'parameters' => ['foo' => 'bar', 'bar' => [1, 2]], 'env' => ['system' => ['os' => 'linux', 'memory' => 8096, 'distribution' => 'debian'], 'vcs' => ['system' => 'git', 'branch' => 'foo']]]), TestUtil::createSuite(['uuid' => '2'])]);
        $this->persister->persist($suiteCollection);
        $suiteCollection = $this->loader->load(new Comparison('$in', 'run', [1, 2]));
        $suites = $suiteCollection->getSuites();
        $this->assertCount(2, $suites);
        $suite = current($suites);
        // assert env information
        $envInformations = $suite->getEnvInformations();
        $this->assertCount(2, $envInformations);
        $this->assertArrayHasKey('system', $envInformations);
        $this->assertEquals('system', $envInformations['system']->getName());
        $this->assertEquals(['os' => 'linux', 'memory' => 8096, 'distribution' => 'debian'], iterator_to_array($envInformations['system']));
        $this->assertArrayHasKey('vcs', $envInformations);
        $this->assertEquals('vcs', $envInformations['vcs']->getName());
        // assert benchmarks
        $benchmarks = $suite->getBenchmarks();
        $this->assertCount(2, $benchmarks);
        $this->assertEquals('BenchOne', $benchmarks[0]->getClass());
        $this->assertEquals('BenchTwo', $benchmarks[1]->getClass());
        // assert subjects
        $subjects = array_values($benchmarks[0]->getSubjects());
        $this->assertCount(2, $subjects);
        $this->assertEquals('benchOne', $subjects[0]->getName());
        $this->assertEquals('benchTwo', $subjects[1]->getName());
        $subject = $subjects[0];
        $this->assertEquals(['one', 'two'], $subject->getGroups());
        $this->assertEquals(9, $subject->getSleep());
        $this->assertEquals('milliseconds', $subject->getOutputTimeUnit());
        $this->assertEquals(7, $subject->getOutputTimePrecision());
        $this->assertEquals('throughput', $subject->getOutputMode());
        // assert variants
        $variants = $subject->getVariants();
        $this->assertCount(1, $variants);
        $variant = current($variants);
        $parameters = $variant->getParameterSet();
        $this->assertEquals(['foo' => 'bar', 'bar' => [1, 2]], $parameters->getArrayCopy());
        $this->assertEquals(5, $variant->getRevolutions());
        $this->assertEquals(2, $variant->getWarmup());
        $variant = current($variants);
        // assert iterations
        $iterations = $variant->getIterations();
        $this->assertCount(2, $iterations);
        $iteration = current($iterations);
        $this->assertEquals(10, $iteration->getResult(TimeResult::class)->getNet());
        $this->assertEquals(200, $iteration->getResult(MemoryResult::class)->getPeak());
    }