<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\TestFixture\TestRunner;

use function realpath;
use SebastianBergmann\CodeCoverage\Data\RawCodeCoverageData;
use SebastianBergmann\CodeCoverage\Driver\Driver;

/**
 * Reports that Covered::value() and NotCovered::value() were executed.
 *
 * Faking the code coverage data keeps the test runner in the child process
 * from starting and stopping a real code coverage driver, which would end the
 * collection of code coverage data for the PHPT test itself.
 */
final class FakeDriver extends Driver
{
    public function name(): string
    {
        return 'FakeDriver';
    }

    public function version(): string
    {
        return '1.0.0';
    }

    public function start(): void
    {
    }

    public function stop(): RawCodeCoverageData
    {
        return RawCodeCoverageData::fromLineCoverage(
            [
                realpath(__DIR__ . '/Covered.php')    => [16 => Driver::LINE_EXECUTED],
                realpath(__DIR__ . '/NotCovered.php') => [16 => Driver::LINE_EXECUTED],
            ],
        );
    }
}
