Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
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
namespace PHPUnit\Util\TestDox;
11
 
12
use function sprintf;
13
use PHPUnit\Framework\TestResult;
14
 
15
/**
16
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
17
 */
18
final class HtmlResultPrinter extends ResultPrinter
19
{
20
    /**
21
     * @var string
22
     */
23
    private const PAGE_HEADER = <<<'EOT'
24
<!doctype html>
25
<html lang="en">
26
    <head>
27
        <meta charset="utf-8"/>
28
        <title>Test Documentation</title>
29
        <style>
30
            body {
31
                text-rendering: optimizeLegibility;
32
                font-variant-ligatures: common-ligatures;
33
                font-kerning: normal;
34
                margin-left: 2em;
35
                background-color: #ffffff;
36
                color: #000000;
37
            }
38
 
39
            body > ul > li {
40
                font-family: Source Serif Pro, PT Sans, Trebuchet MS, Helvetica, Arial;
41
                font-size: 2em;
42
            }
43
 
44
            h2 {
45
                font-family: Tahoma, Helvetica, Arial;
46
                font-size: 3em;
47
            }
48
 
49
            ul {
50
                list-style: none;
51
                margin-bottom: 1em;
52
            }
53
        </style>
54
    </head>
55
    <body>
56
EOT;
57
 
58
    /**
59
     * @var string
60
     */
61
    private const CLASS_HEADER = <<<'EOT'
62
 
63
        <h2 id="%s">%s</h2>
64
        <ul>
65
 
66
EOT;
67
 
68
    /**
69
     * @var string
70
     */
71
    private const CLASS_FOOTER = <<<'EOT'
72
        </ul>
73
EOT;
74
 
75
    /**
76
     * @var string
77
     */
78
    private const PAGE_FOOTER = <<<'EOT'
79
 
80
    </body>
81
</html>
82
EOT;
83
 
84
    public function printResult(TestResult $result): void
85
    {
86
    }
87
 
88
    /**
89
     * Handler for 'start run' event.
90
     */
91
    protected function startRun(): void
92
    {
93
        $this->write(self::PAGE_HEADER);
94
    }
95
 
96
    /**
97
     * Handler for 'start class' event.
98
     */
99
    protected function startClass(string $name): void
100
    {
101
        $this->write(
102
            sprintf(
103
                self::CLASS_HEADER,
104
                $name,
105
                $this->currentTestClassPrettified
106
            )
107
        );
108
    }
109
 
110
    /**
111
     * Handler for 'on test' event.
112
     */
113
    protected function onTest(string $name, bool $success = true): void
114
    {
115
        $this->write(
116
            sprintf(
117
                "            <li style=\"color: %s;\">%s %s</li>\n",
118
                $success ? '#555753' : '#ef2929',
119
                $success ? '✓' : '❌',
120
                $name
121
            )
122
        );
123
    }
124
 
125
    /**
126
     * Handler for 'end class' event.
127
     */
128
    protected function endClass(string $name): void
129
    {
130
        $this->write(self::CLASS_FOOTER);
131
    }
132
 
133
    /**
134
     * Handler for 'end run' event.
135
     */
136
    protected function endRun(): void
137
    {
138
        $this->write(self::PAGE_FOOTER);
139
    }
140
}