Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | 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;
991 lars 32
                font-family: Source SansSerif Pro, Arial, sans-serif;
148 lars 33
                font-variant-ligatures: common-ligatures;
34
                font-kerning: normal;
991 lars 35
                margin-left: 2rem;
36
                background-color: #fff;
37
                color: #000;
148 lars 38
            }
39
 
40
            body > ul > li {
991 lars 41
                font-size: larger;
148 lars 42
            }
43
 
44
            h2 {
991 lars 45
                font-size: larger;
46
                text-decoration-line: underline;
47
                text-decoration-thickness: 2px;
48
                margin: 0;
49
                padding: 0.5rem 0;
148 lars 50
            }
51
 
52
            ul {
53
                list-style: none;
991 lars 54
                margin: 0 0 2rem;
55
                padding: 0 0 0 1rem;
56
                text-indent: -1rem;
148 lars 57
            }
991 lars 58
 
59
            .success:before {
60
                color: #4e9a06;
61
                content: '✓';
62
                padding-right: 0.5rem;
63
            }
64
 
65
            .defect {
66
                color: #a40000;
67
            }
68
 
69
            .defect:before {
70
                color: #a40000;
71
                content: '✗';
72
                padding-right: 0.5rem;
73
            }
148 lars 74
        </style>
75
    </head>
76
    <body>
77
EOT;
78
 
79
    /**
80
     * @var string
81
     */
82
    private const CLASS_HEADER = <<<'EOT'
83
 
991 lars 84
        <h2>%s</h2>
148 lars 85
        <ul>
86
 
87
EOT;
88
 
89
    /**
90
     * @var string
91
     */
92
    private const CLASS_FOOTER = <<<'EOT'
93
        </ul>
94
EOT;
95
 
96
    /**
97
     * @var string
98
     */
99
    private const PAGE_FOOTER = <<<'EOT'
100
 
101
    </body>
102
</html>
103
EOT;
104
 
105
    public function printResult(TestResult $result): void
106
    {
107
    }
108
 
109
    /**
110
     * Handler for 'start run' event.
111
     */
112
    protected function startRun(): void
113
    {
114
        $this->write(self::PAGE_HEADER);
115
    }
116
 
117
    /**
118
     * Handler for 'start class' event.
119
     */
120
    protected function startClass(string $name): void
121
    {
122
        $this->write(
123
            sprintf(
124
                self::CLASS_HEADER,
125
                $this->currentTestClassPrettified
126
            )
127
        );
128
    }
129
 
130
    /**
131
     * Handler for 'on test' event.
132
     */
133
    protected function onTest(string $name, bool $success = true): void
134
    {
135
        $this->write(
136
            sprintf(
991 lars 137
                "            <li class=\"%s\">%s</li>\n",
138
                $success ? 'success' : 'defect',
148 lars 139
                $name
140
            )
141
        );
142
    }
143
 
144
    /**
145
     * Handler for 'end class' event.
146
     */
147
    protected function endClass(string $name): void
148
    {
149
        $this->write(self::CLASS_FOOTER);
150
    }
151
 
152
    /**
153
     * Handler for 'end run' event.
154
     */
155
    protected function endRun(): void
156
    {
157
        $this->write(self::PAGE_FOOTER);
158
    }
159
}