1<?php
2/*
3 * This file is part of PHPUnit.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11class PHPUnit_Util_ConfigurationGenerator
12{
13    /**
14     * @var string
15     */
16    private $defaultTemplate = <<<EOT
17<?xml version="1.0" encoding="UTF-8"?>
18<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19         xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/{phpunit_version}/phpunit.xsd"
20         bootstrap="{bootstrap_script}"
21         backupGlobals="false"
22         beStrictAboutCoversAnnotation="true"
23         beStrictAboutOutputDuringTests="true"
24         beStrictAboutTestsThatDoNotTestAnything="true"
25         beStrictAboutTodoAnnotatedTests="true"
26         verbose="true">
27    <testsuite name="default">
28        <directory suffix="Test.php">{tests_directory}</directory>
29    </testsuite>
30
31    <filter>
32        <whitelist processUncoveredFilesFromWhitelist="true">
33            <directory suffix=".php">{src_directory}</directory>
34        </whitelist>
35    </filter>
36</phpunit>
37
38EOT;
39
40    /**
41     * @param string $phpunitVersion
42     * @param string $bootstrapScript
43     * @param string $testsDirectory
44     * @param string $srcDirectory
45     *
46     * @return string
47     */
48    public function generateDefaultConfiguration($phpunitVersion, $bootstrapScript, $testsDirectory, $srcDirectory)
49    {
50        return str_replace(
51            [
52                '{phpunit_version}',
53                '{bootstrap_script}',
54                '{tests_directory}',
55                '{src_directory}'
56            ],
57            [
58                $phpunitVersion,
59                $bootstrapScript,
60                $testsDirectory,
61                $srcDirectory
62            ],
63            $this->defaultTemplate
64        );
65    }
66}
67