Subversion-Projekte lars-tiefland.laravel_shop

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;
11
 
12
use const PHP_EOL;
13
use function get_class;
14
use function sprintf;
15
use function str_replace;
16
use PHPUnit\Framework\TestCase;
17
use PHPUnit\Framework\TestSuite;
18
use PHPUnit\Runner\PhptTestCase;
19
use RecursiveIteratorIterator;
20
 
21
/**
22
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
23
 */
24
final class TextTestListRenderer
25
{
26
    /**
27
     * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
28
     */
29
    public function render(TestSuite $suite): string
30
    {
31
        $buffer = 'Available test(s):' . PHP_EOL;
32
 
33
        foreach (new RecursiveIteratorIterator($suite->getIterator()) as $test) {
34
            if ($test instanceof TestCase) {
35
                $name = sprintf(
36
                    '%s::%s',
37
                    get_class($test),
38
                    str_replace(' with data set ', '', $test->getName())
39
                );
40
            } elseif ($test instanceof PhptTestCase) {
41
                $name = $test->getName();
42
            } else {
43
                continue;
44
            }
45
 
46
            $buffer .= sprintf(
47
                ' - %s' . PHP_EOL,
48
                $name
49
            );
50
        }
51
 
52
        return $buffer;
53
    }
54
}