Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
use PHPUnit\Framework\TestCase;
3
use SebastianBergmann\CodeCoverage\CodeCoverage;
4
use SebastianBergmann\CodeCoverage\Driver\Selector;
5
use PHPUnit\TextUI\XmlConfiguration\Loader;
6
use PHPUnit\TextUI\XmlConfiguration\PhpHandler;
7
 
8
if (!defined('STDOUT')) {
9
    // php://stdout does not obey output buffering. Any output would break
10
    // unserialization of child process results in the parent process.
11
    define('STDOUT', fopen('php://temp', 'w+b'));
12
    define('STDERR', fopen('php://stderr', 'wb'));
13
}
14
 
15
{iniSettings}
16
ini_set('display_errors', 'stderr');
17
set_include_path('{include_path}');
18
 
19
$composerAutoload = {composerAutoload};
20
$phar             = {phar};
21
 
22
ob_start();
23
 
24
if ($composerAutoload) {
25
    require_once $composerAutoload;
26
    define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload);
27
} else if ($phar) {
28
    require $phar;
29
}
30
 
31
function __phpunit_run_isolated_test()
32
{
33
    if (!class_exists('{className}')) {
34
        require_once '{filename}';
35
    }
36
 
37
    $result = new PHPUnit\Framework\TestResult;
38
 
39
    if ({collectCodeCoverageInformation}) {
40
        $filter = unserialize('{codeCoverageFilter}');
41
 
42
        $codeCoverage = new CodeCoverage(
43
            (new Selector)->{driverMethod}($filter),
44
            $filter
45
        );
46
 
47
        if ({cachesStaticAnalysis}) {
48
            $codeCoverage->cacheStaticAnalysis(unserialize('{codeCoverageCacheDirectory}'));
49
        }
50
 
51
        $result->setCodeCoverage($codeCoverage);
52
    }
53
 
54
    $result->beStrictAboutTestsThatDoNotTestAnything({isStrictAboutTestsThatDoNotTestAnything});
55
    $result->beStrictAboutOutputDuringTests({isStrictAboutOutputDuringTests});
56
    $result->enforceTimeLimit({enforcesTimeLimit});
57
    $result->beStrictAboutTodoAnnotatedTests({isStrictAboutTodoAnnotatedTests});
58
    $result->beStrictAboutResourceUsageDuringSmallTests({isStrictAboutResourceUsageDuringSmallTests});
59
 
60
    $test = new {className}('{methodName}', unserialize('{data}'), '{dataName}');
61
    \assert($test instanceof TestCase);
62
 
63
    $test->setDependencyInput(unserialize('{dependencyInput}'));
64
    $test->setInIsolation(true);
65
 
66
    ob_end_clean();
67
    $test->run($result);
68
    $output = '';
69
    if (!$test->hasExpectationOnOutput()) {
70
        $output = $test->getActualOutput();
71
    }
72
 
73
    ini_set('xdebug.scream', '0');
74
    @rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
75
    if ($stdout = @stream_get_contents(STDOUT)) {
76
        $output = $stdout . $output;
77
        $streamMetaData = stream_get_meta_data(STDOUT);
78
        if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) {
79
            @ftruncate(STDOUT, 0);
80
            @rewind(STDOUT);
81
        }
82
    }
83
 
84
    print serialize(
85
      [
86
        'testResult'    => $test->getResult(),
87
        'numAssertions' => $test->getNumAssertions(),
88
        'result'        => $result,
89
        'output'        => $output
90
      ]
91
    );
92
}
93
 
94
$configurationFilePath = '{configurationFilePath}';
95
 
96
if ('' !== $configurationFilePath) {
97
    $configuration = (new Loader)->load($configurationFilePath);
98
 
99
    (new PhpHandler)->handle($configuration->php());
100
 
101
    unset($configuration);
102
}
103
 
104
function __phpunit_error_handler($errno, $errstr, $errfile, $errline)
105
{
106
   return true;
107
}
108
 
109
set_error_handler('__phpunit_error_handler');
110
 
111
{constants}
112
{included_files}
113
{globals}
114
 
115
restore_error_handler();
116
 
117
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
118
    require_once $GLOBALS['__PHPUNIT_BOOTSTRAP'];
119
    unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
120
}
121
 
122
__phpunit_run_isolated_test();