• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JBZoo / PHPUnit / 6888280005

14 Oct 2023 08:28PM UTC coverage: 67.46%. Remained the same
6888280005

push

github

web-flow
PHP CS Fixer - `ordered_types` (#29)

170 of 252 relevant lines covered (67.46%)

4.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/fake-index.php
1
<?php
2

3
/**
4
 * JBZoo Toolbox - PHPUnit.
5
 *
6
 * This file is part of the JBZoo Toolbox project.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT
11
 * @copyright  Copyright (C) JBZoo.com, All rights reserved.
12
 * @see        https://github.com/JBZoo/PHPUnit
13
 */
14

15
declare(strict_types=1);
16

17
namespace JBZoo\PHPUnit;
18

19
use GetOpt\GetOpt;
20
use JBZoo\Utils\Env;
21
use JBZoo\Utils\Sys;
22

23
use function JBZoo\Data\data;
24

25
// To help the built-in PHP dev server, check if the request was actually for
26
// something which should probably be served as a static file
27
if (\PHP_SAPI !== 'cli-server') {
×
28
    return null;
×
29
}
30

31
$url            = (array)\parse_url($_SERVER['REQUEST_URI'] ?? '');
×
32
$currentUrlPath = '';
×
33
if (\array_key_exists('path', $url)) {
×
34
    $currentUrlPath = (string)\realpath(($_SERVER['DOCUMENT_ROOT'] ?? '') . $url['path']);
×
35
}
36

37
if ($currentUrlPath !== '') {
×
38
    if (\is_dir($currentUrlPath)) {
×
39
        $realIndex = $currentUrlPath . '/index.php';
×
40
    } elseif (\is_file($currentUrlPath)) {
×
41
        if (\pathinfo($currentUrlPath, \PATHINFO_EXTENSION) !== 'php') {
×
42
            return false;
×
43
        }
44
        $realIndex = $currentUrlPath;
×
45
    }
46
}
47

48
// Try to find and load composer autoloader
49
$vendorPaths = [
×
50
    \realpath(__DIR__ . '/vendor/autoload.php'),
×
51
    \dirname(__DIR__) . '/vendor/autoload.php',
×
52
    \dirname(__DIR__, 2) . '/vendor/autoload.php',
×
53
    \dirname(__DIR__, 3) . '/vendor/autoload.php',
×
54
    \dirname(__DIR__, 4) . '/vendor/autoload.php',
×
55
    \dirname(__DIR__, 5) . '/vendor/autoload.php',
×
56
    \realpath('./vendor/autoload.php'),
×
57
];
58

59
foreach ($vendorPaths as $vendorPath) {
×
60
    $vendorPath = (string)$vendorPath;
×
61

62
    /** @psalm-suppress UnresolvableInclude */
63
    if ($vendorPath !== '' && \file_exists($vendorPath)) {
×
64
        require_once $vendorPath;
×
65
        break;
×
66
    }
67
}
68

69
// Parse additional options
70
$cliOptions = new Getopt([
×
71
    [null, 'index', GetOpt::OPTIONAL_ARGUMENT],
72
    [null, 'cov-src', GetOpt::OPTIONAL_ARGUMENT],
73
    [null, 'cov-xml', GetOpt::OPTIONAL_ARGUMENT],
74
    [null, 'cov-cov', GetOpt::OPTIONAL_ARGUMENT],
75
    [null, 'cov-html', GetOpt::OPTIONAL_ARGUMENT],
76
]);
77

78
$cliOptions->process(Env::string('PHPUNINT_ARGUMENTS'));
×
79

80
$realIndex = (string)($realIndex ?? \realpath($cliOptions->getOption('index')));
×
81

82
if (\class_exists(CovCatcher::class) && Sys::hasXdebug()) {
×
83
    $testname = (string)data($_REQUEST)->get('testname');
×
84
    \putenv('XDEBUG_MODE=' . Env::string('XDEBUG_MODE', 'coverage'));
×
85

86
    $coverHash = \md5(\implode('||', [\serialize($_REQUEST), \serialize($_SERVER), \PHP_VERSION]));
×
87
    $coverHash = $testname !== '' ? $testname . '-' . $coverHash : $testname;
×
88

89
    $covCatcher = new CovCatcher($coverHash, [
×
90
        'src'  => $cliOptions->getOption('cov-src'),
×
91
        'xml'  => $cliOptions->getOption('cov-xml'),
×
92
        'cov'  => $cliOptions->getOption('cov-cov'),
×
93
        'html' => $cliOptions->getOption('cov-html'),
×
94
    ]);
95

96
    $result = $covCatcher->includeFile($realIndex);
×
97
} elseif (\file_exists($realIndex)) {
×
98
    $result = require $realIndex;
×
99
} else {
100
    $result = null;
×
101
}
102

103
return $result;
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc