init
This commit is contained in:
113
vendor/phpunit/phpunit/src/Util/Blacklist.php
vendored
Normal file
113
vendor/phpunit/phpunit/src/Util/Blacklist.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Utility class for blacklisting PHPUnit's own source code files.
|
||||
*/
|
||||
class Blacklist
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public static $blacklistedClassNames = [
|
||||
'File_Iterator' => 1,
|
||||
'PHP_Invoker' => 1,
|
||||
'PHP_Timer' => 1,
|
||||
'PHP_Token' => 1,
|
||||
'PHPUnit\Framework\TestCase' => 2,
|
||||
'PHPUnit\DbUnit\TestCase' => 2,
|
||||
'PHPUnit\Framework\MockObject\Generator' => 1,
|
||||
'Text_Template' => 1,
|
||||
'Symfony\Component\Yaml\Yaml' => 1,
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage' => 1,
|
||||
'SebastianBergmann\Diff\Diff' => 1,
|
||||
'SebastianBergmann\Environment\Runtime' => 1,
|
||||
'SebastianBergmann\Comparator\Comparator' => 1,
|
||||
'SebastianBergmann\Exporter\Exporter' => 1,
|
||||
'SebastianBergmann\GlobalState\Snapshot' => 1,
|
||||
'SebastianBergmann\RecursionContext\Context' => 1,
|
||||
'SebastianBergmann\Version' => 1,
|
||||
'Composer\Autoload\ClassLoader' => 1,
|
||||
'Doctrine\Instantiator\Instantiator' => 1,
|
||||
'phpDocumentor\Reflection\DocBlock' => 1,
|
||||
'Prophecy\Prophet' => 1,
|
||||
'DeepCopy\DeepCopy' => 1
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private static $directories;
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getBlacklistedDirectories()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return self::$directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isBlacklisted($file)
|
||||
{
|
||||
if (\defined('PHPUNIT_TESTSUITE')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->initialize();
|
||||
|
||||
foreach (self::$directories as $directory) {
|
||||
if (\strpos($file, $directory) === 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function initialize()
|
||||
{
|
||||
if (self::$directories === null) {
|
||||
self::$directories = [];
|
||||
|
||||
foreach (self::$blacklistedClassNames as $className => $parent) {
|
||||
if (!\class_exists($className)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reflector = new ReflectionClass($className);
|
||||
$directory = $reflector->getFileName();
|
||||
|
||||
for ($i = 0; $i < $parent; $i++) {
|
||||
$directory = \dirname($directory);
|
||||
}
|
||||
|
||||
self::$directories[] = $directory;
|
||||
}
|
||||
|
||||
// Hide process isolation workaround on Windows.
|
||||
if (DIRECTORY_SEPARATOR === '\\') {
|
||||
// tempnam() prefix is limited to first 3 chars.
|
||||
// @see http://php.net/manual/en/function.tempnam.php
|
||||
self::$directories[] = \sys_get_temp_dir() . '\\PHP';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1208
vendor/phpunit/phpunit/src/Util/Configuration.php
vendored
Normal file
1208
vendor/phpunit/phpunit/src/Util/Configuration.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
67
vendor/phpunit/phpunit/src/Util/ConfigurationGenerator.php
vendored
Normal file
67
vendor/phpunit/phpunit/src/Util/ConfigurationGenerator.php
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
class ConfigurationGenerator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $defaultTemplate = <<<EOT
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/{phpunit_version}/phpunit.xsd"
|
||||
bootstrap="{bootstrap_script}"
|
||||
forceCoversAnnotation="true"
|
||||
beStrictAboutCoversAnnotation="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
beStrictAboutTodoAnnotatedTests="true"
|
||||
verbose="true">
|
||||
<testsuite name="default">
|
||||
<directory suffix="Test.php">{tests_directory}</directory>
|
||||
</testsuite>
|
||||
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">{src_directory}</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
EOT;
|
||||
|
||||
/**
|
||||
* @param string $phpunitVersion
|
||||
* @param string $bootstrapScript
|
||||
* @param string $testsDirectory
|
||||
* @param string $srcDirectory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateDefaultConfiguration($phpunitVersion, $bootstrapScript, $testsDirectory, $srcDirectory)
|
||||
{
|
||||
return \str_replace(
|
||||
[
|
||||
'{phpunit_version}',
|
||||
'{bootstrap_script}',
|
||||
'{tests_directory}',
|
||||
'{src_directory}'
|
||||
],
|
||||
[
|
||||
$phpunitVersion,
|
||||
$bootstrapScript,
|
||||
$testsDirectory,
|
||||
$srcDirectory
|
||||
],
|
||||
$this->defaultTemplate
|
||||
);
|
||||
}
|
||||
}
|
||||
118
vendor/phpunit/phpunit/src/Util/ErrorHandler.php
vendored
Normal file
118
vendor/phpunit/phpunit/src/Util/ErrorHandler.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Error\Deprecated;
|
||||
use PHPUnit\Framework\Error\Error;
|
||||
use PHPUnit\Framework\Error\Notice;
|
||||
use PHPUnit\Framework\Error\Warning;
|
||||
|
||||
/**
|
||||
* Error handler that converts PHP errors and warnings to exceptions.
|
||||
*/
|
||||
class ErrorHandler
|
||||
{
|
||||
protected static $errorStack = [];
|
||||
|
||||
/**
|
||||
* Returns the error stack.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getErrorStack()
|
||||
{
|
||||
return self::$errorStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $errno
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param int $errline
|
||||
*
|
||||
* @return false
|
||||
*
|
||||
* @throws Error
|
||||
*/
|
||||
public static function handleError($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if (!($errno & \error_reporting())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
self::$errorStack[] = [$errno, $errstr, $errfile, $errline];
|
||||
|
||||
$trace = \debug_backtrace();
|
||||
\array_shift($trace);
|
||||
|
||||
foreach ($trace as $frame) {
|
||||
if ($frame['function'] == '__toString') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
|
||||
if (Notice::$enabled !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$exception = Notice::class;
|
||||
} elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
|
||||
if (Warning::$enabled !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$exception = Warning::class;
|
||||
} elseif ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
|
||||
if (Deprecated::$enabled !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$exception = Deprecated::class;
|
||||
} else {
|
||||
$exception = Error::class;
|
||||
}
|
||||
|
||||
throw new $exception($errstr, $errno, $errfile, $errline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an error handler and returns a function that will restore
|
||||
* the previous handler when invoked
|
||||
*
|
||||
* @param int $severity PHP predefined error constant
|
||||
*
|
||||
* @return \Closure
|
||||
*
|
||||
* @throws \Exception if event of specified severity is emitted
|
||||
*/
|
||||
public static function handleErrorOnce($severity = E_WARNING)
|
||||
{
|
||||
$terminator = function () {
|
||||
static $expired = false;
|
||||
if (!$expired) {
|
||||
$expired = true;
|
||||
// cleans temporary error handler
|
||||
return \restore_error_handler();
|
||||
}
|
||||
};
|
||||
|
||||
\set_error_handler(function ($errno, $errstr) use ($severity) {
|
||||
if ($errno === $severity) {
|
||||
return;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return $terminator;
|
||||
}
|
||||
}
|
||||
80
vendor/phpunit/phpunit/src/Util/Fileloader.php
vendored
Normal file
80
vendor/phpunit/phpunit/src/Util/Fileloader.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Utility methods to load PHP sourcefiles.
|
||||
*/
|
||||
class Fileloader
|
||||
{
|
||||
/**
|
||||
* Checks if a PHP sourcefile is readable.
|
||||
* The sourcefile is loaded through the load() method.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function checkAndLoad($filename)
|
||||
{
|
||||
$includePathFilename = \stream_resolve_include_path($filename);
|
||||
|
||||
// As a fallback, PHP looks in the directory of the file executing the stream_resolve_include_path function.
|
||||
// We don't want to load the Test.php file here, so skip it if it found that.
|
||||
// PHP prioritizes the include_path setting, so if the current directory is in there, it will first look in the
|
||||
// current working directory.
|
||||
$localFile = __DIR__ . DIRECTORY_SEPARATOR . $filename;
|
||||
|
||||
// @see https://github.com/sebastianbergmann/phpunit/pull/2751
|
||||
$isReadable = @\fopen($includePathFilename, 'r') !== false;
|
||||
|
||||
if (!$includePathFilename || !$isReadable || $includePathFilename === $localFile) {
|
||||
throw new Exception(
|
||||
\sprintf('Cannot open file "%s".' . "\n", $filename)
|
||||
);
|
||||
}
|
||||
|
||||
self::load($includePathFilename);
|
||||
|
||||
return $includePathFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a PHP sourcefile.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function load($filename)
|
||||
{
|
||||
$oldVariableNames = \array_keys(\get_defined_vars());
|
||||
|
||||
include_once $filename;
|
||||
|
||||
$newVariables = \get_defined_vars();
|
||||
$newVariableNames = \array_diff(
|
||||
\array_keys($newVariables),
|
||||
$oldVariableNames
|
||||
);
|
||||
|
||||
foreach ($newVariableNames as $variableName) {
|
||||
if ($variableName != 'oldVariableNames') {
|
||||
$GLOBALS[$variableName] = $newVariables[$variableName];
|
||||
}
|
||||
}
|
||||
|
||||
return $filename;
|
||||
}
|
||||
}
|
||||
40
vendor/phpunit/phpunit/src/Util/Filesystem.php
vendored
Normal file
40
vendor/phpunit/phpunit/src/Util/Filesystem.php
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
/**
|
||||
* Filesystem helpers.
|
||||
*/
|
||||
class Filesystem
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $buffer = [];
|
||||
|
||||
/**
|
||||
* Maps class names to source file names:
|
||||
* - PEAR CS: Foo_Bar_Baz -> Foo/Bar/Baz.php
|
||||
* - Namespace: Foo\Bar\Baz -> Foo/Bar/Baz.php
|
||||
*
|
||||
* @param string $className
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function classNameToFilename($className)
|
||||
{
|
||||
return \str_replace(
|
||||
['_', '\\'],
|
||||
DIRECTORY_SEPARATOR,
|
||||
$className
|
||||
) . '.php';
|
||||
}
|
||||
}
|
||||
107
vendor/phpunit/phpunit/src/Util/Filter.php
vendored
Normal file
107
vendor/phpunit/phpunit/src/Util/Filter.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
use PHPUnit\Framework\SyntheticError;
|
||||
|
||||
/**
|
||||
* Utility class for code filtering.
|
||||
*/
|
||||
class Filter
|
||||
{
|
||||
/**
|
||||
* Filters stack frames from PHPUnit classes.
|
||||
*
|
||||
* @param \Throwable $e
|
||||
* @param bool $asString
|
||||
*
|
||||
* @return string|string[]
|
||||
*/
|
||||
public static function getFilteredStacktrace($e, $asString = true)
|
||||
{
|
||||
$prefix = false;
|
||||
$script = \realpath($GLOBALS['_SERVER']['SCRIPT_NAME']);
|
||||
|
||||
if (\defined('__PHPUNIT_PHAR_ROOT__')) {
|
||||
$prefix = __PHPUNIT_PHAR_ROOT__;
|
||||
}
|
||||
|
||||
if ($asString === true) {
|
||||
$filteredStacktrace = '';
|
||||
} else {
|
||||
$filteredStacktrace = [];
|
||||
}
|
||||
|
||||
if ($e instanceof SyntheticError) {
|
||||
$eTrace = $e->getSyntheticTrace();
|
||||
$eFile = $e->getSyntheticFile();
|
||||
$eLine = $e->getSyntheticLine();
|
||||
} elseif ($e instanceof Exception) {
|
||||
$eTrace = $e->getSerializableTrace();
|
||||
$eFile = $e->getFile();
|
||||
$eLine = $e->getLine();
|
||||
} else {
|
||||
if ($e->getPrevious()) {
|
||||
$e = $e->getPrevious();
|
||||
}
|
||||
$eTrace = $e->getTrace();
|
||||
$eFile = $e->getFile();
|
||||
$eLine = $e->getLine();
|
||||
}
|
||||
|
||||
if (!self::frameExists($eTrace, $eFile, $eLine)) {
|
||||
\array_unshift(
|
||||
$eTrace,
|
||||
['file' => $eFile, 'line' => $eLine]
|
||||
);
|
||||
}
|
||||
|
||||
$blacklist = new Blacklist;
|
||||
|
||||
foreach ($eTrace as $frame) {
|
||||
if (isset($frame['file']) && \is_file($frame['file']) &&
|
||||
!$blacklist->isBlacklisted($frame['file']) &&
|
||||
($prefix === false || \strpos($frame['file'], $prefix) !== 0) &&
|
||||
$frame['file'] !== $script) {
|
||||
if ($asString === true) {
|
||||
$filteredStacktrace .= \sprintf(
|
||||
"%s:%s\n",
|
||||
$frame['file'],
|
||||
$frame['line'] ?? '?'
|
||||
);
|
||||
} else {
|
||||
$filteredStacktrace[] = $frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $filteredStacktrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $trace
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function frameExists(array $trace, $file, $line)
|
||||
{
|
||||
foreach ($trace as $frame) {
|
||||
if (isset($frame['file']) && $frame['file'] == $file &&
|
||||
isset($frame['line']) && $frame['line'] == $line) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
166
vendor/phpunit/phpunit/src/Util/Getopt.php
vendored
Normal file
166
vendor/phpunit/phpunit/src/Util/Getopt.php
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Command-line options parsing class.
|
||||
*/
|
||||
class Getopt
|
||||
{
|
||||
public static function getopt(array $args, $short_options, $long_options = null)
|
||||
{
|
||||
if (empty($args)) {
|
||||
return [[], []];
|
||||
}
|
||||
|
||||
$opts = [];
|
||||
$non_opts = [];
|
||||
|
||||
if ($long_options) {
|
||||
\sort($long_options);
|
||||
}
|
||||
|
||||
if (isset($args[0][0]) && $args[0][0] != '-') {
|
||||
\array_shift($args);
|
||||
}
|
||||
|
||||
\reset($args);
|
||||
|
||||
$args = \array_map('trim', $args);
|
||||
|
||||
while (false !== $arg = \current($args)) {
|
||||
$i = \key($args);
|
||||
\next($args);
|
||||
if ($arg == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($arg == '--') {
|
||||
$non_opts = \array_merge($non_opts, \array_slice($args, $i + 1));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if ($arg[0] != '-' || (\strlen($arg) > 1 && $arg[1] == '-' && !$long_options)) {
|
||||
$non_opts[] = $args[$i];
|
||||
|
||||
continue;
|
||||
} elseif (\strlen($arg) > 1 && $arg[1] == '-') {
|
||||
self::parseLongOption(
|
||||
\substr($arg, 2),
|
||||
$long_options,
|
||||
$opts,
|
||||
$args
|
||||
);
|
||||
} else {
|
||||
self::parseShortOption(
|
||||
\substr($arg, 1),
|
||||
$short_options,
|
||||
$opts,
|
||||
$args
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return [$opts, $non_opts];
|
||||
}
|
||||
|
||||
protected static function parseShortOption($arg, $short_options, &$opts, &$args)
|
||||
{
|
||||
$argLen = \strlen($arg);
|
||||
|
||||
for ($i = 0; $i < $argLen; $i++) {
|
||||
$opt = $arg[$i];
|
||||
$opt_arg = null;
|
||||
|
||||
if (($spec = \strstr($short_options, $opt)) === false || $arg[$i] == ':') {
|
||||
throw new Exception(
|
||||
"unrecognized option -- $opt"
|
||||
);
|
||||
}
|
||||
|
||||
if (\strlen($spec) > 1 && $spec[1] == ':') {
|
||||
if ($i + 1 < $argLen) {
|
||||
$opts[] = [$opt, \substr($arg, $i + 1)];
|
||||
|
||||
break;
|
||||
}
|
||||
if (!(\strlen($spec) > 2 && $spec[2] == ':')) {
|
||||
if (false === $opt_arg = \current($args)) {
|
||||
throw new Exception(
|
||||
"option requires an argument -- $opt"
|
||||
);
|
||||
}
|
||||
\next($args);
|
||||
}
|
||||
}
|
||||
|
||||
$opts[] = [$opt, $opt_arg];
|
||||
}
|
||||
}
|
||||
|
||||
protected static function parseLongOption($arg, $long_options, &$opts, &$args)
|
||||
{
|
||||
$count = \count($long_options);
|
||||
$list = \explode('=', $arg);
|
||||
$opt = $list[0];
|
||||
$opt_arg = null;
|
||||
|
||||
if (\count($list) > 1) {
|
||||
$opt_arg = $list[1];
|
||||
}
|
||||
|
||||
$opt_len = \strlen($opt);
|
||||
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$long_opt = $long_options[$i];
|
||||
$opt_start = \substr($long_opt, 0, $opt_len);
|
||||
|
||||
if ($opt_start != $opt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$opt_rest = \substr($long_opt, $opt_len);
|
||||
|
||||
if ($opt_rest != '' && $opt[0] != '=' && $i + 1 < $count &&
|
||||
$opt == \substr($long_options[$i + 1], 0, $opt_len)) {
|
||||
throw new Exception(
|
||||
"option --$opt is ambiguous"
|
||||
);
|
||||
}
|
||||
|
||||
if (\substr($long_opt, -1) == '=') {
|
||||
if (\substr($long_opt, -2) != '==') {
|
||||
if (!\strlen($opt_arg)) {
|
||||
if (false === $opt_arg = \current($args)) {
|
||||
throw new Exception(
|
||||
"option --$opt requires an argument"
|
||||
);
|
||||
}
|
||||
\next($args);
|
||||
}
|
||||
}
|
||||
} elseif ($opt_arg) {
|
||||
throw new Exception(
|
||||
"option --$opt doesn't allow an argument"
|
||||
);
|
||||
}
|
||||
|
||||
$full_option = '--' . \preg_replace('/={1,2}$/', '', $long_opt);
|
||||
$opts[] = [$full_option, $opt_arg];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception("unrecognized option --$opt");
|
||||
}
|
||||
}
|
||||
202
vendor/phpunit/phpunit/src/Util/GlobalState.php
vendored
Normal file
202
vendor/phpunit/phpunit/src/Util/GlobalState.php
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use Closure;
|
||||
|
||||
class GlobalState
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $superGlobalArrays = [
|
||||
'_ENV',
|
||||
'_POST',
|
||||
'_GET',
|
||||
'_COOKIE',
|
||||
'_SERVER',
|
||||
'_FILES',
|
||||
'_REQUEST'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIncludedFilesAsString()
|
||||
{
|
||||
return static::processIncludedFilesAsString(\get_included_files());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $files
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function processIncludedFilesAsString(array $files)
|
||||
{
|
||||
$blacklist = new Blacklist;
|
||||
$prefix = false;
|
||||
$result = '';
|
||||
|
||||
if (\defined('__PHPUNIT_PHAR__')) {
|
||||
$prefix = 'phar://' . __PHPUNIT_PHAR__ . '/';
|
||||
}
|
||||
|
||||
for ($i = \count($files) - 1; $i > 0; $i--) {
|
||||
$file = $files[$i];
|
||||
|
||||
if (!empty($GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST']) &&
|
||||
\in_array($file, $GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($prefix !== false && \strpos($file, $prefix) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip virtual file system protocols
|
||||
if (\preg_match('/^(vfs|phpvfs[a-z0-9]+):/', $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$blacklist->isBlacklisted($file) && \is_file($file)) {
|
||||
$result = 'require_once \'' . $file . "';\n" . $result;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getIniSettingsAsString()
|
||||
{
|
||||
$result = '';
|
||||
$iniSettings = \ini_get_all(null, false);
|
||||
|
||||
foreach ($iniSettings as $key => $value) {
|
||||
$result .= \sprintf(
|
||||
'@ini_set(%s, %s);' . "\n",
|
||||
self::exportVariable($key),
|
||||
self::exportVariable($value)
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getConstantsAsString()
|
||||
{
|
||||
$constants = \get_defined_constants(true);
|
||||
$result = '';
|
||||
|
||||
if (isset($constants['user'])) {
|
||||
foreach ($constants['user'] as $name => $value) {
|
||||
$result .= \sprintf(
|
||||
'if (!defined(\'%s\')) define(\'%s\', %s);' . "\n",
|
||||
$name,
|
||||
$name,
|
||||
self::exportVariable($value)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getGlobalsAsString()
|
||||
{
|
||||
$result = '';
|
||||
$superGlobalArrays = self::getSuperGlobalArrays();
|
||||
|
||||
foreach ($superGlobalArrays as $superGlobalArray) {
|
||||
if (isset($GLOBALS[$superGlobalArray]) && \is_array($GLOBALS[$superGlobalArray])) {
|
||||
foreach (\array_keys($GLOBALS[$superGlobalArray]) as $key) {
|
||||
if ($GLOBALS[$superGlobalArray][$key] instanceof Closure) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result .= \sprintf(
|
||||
'$GLOBALS[\'%s\'][\'%s\'] = %s;' . "\n",
|
||||
$superGlobalArray,
|
||||
$key,
|
||||
self::exportVariable($GLOBALS[$superGlobalArray][$key])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$blacklist = $superGlobalArrays;
|
||||
$blacklist[] = 'GLOBALS';
|
||||
|
||||
foreach (\array_keys($GLOBALS) as $key) {
|
||||
if (!\in_array($key, $blacklist) && !$GLOBALS[$key] instanceof Closure) {
|
||||
$result .= \sprintf(
|
||||
'$GLOBALS[\'%s\'] = %s;' . "\n",
|
||||
$key,
|
||||
self::exportVariable($GLOBALS[$key])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected static function getSuperGlobalArrays()
|
||||
{
|
||||
return self::$superGlobalArrays;
|
||||
}
|
||||
|
||||
protected static function exportVariable($variable)
|
||||
{
|
||||
if (\is_scalar($variable) || null === $variable ||
|
||||
(\is_array($variable) && self::arrayOnlyContainsScalars($variable))) {
|
||||
return \var_export($variable, true);
|
||||
}
|
||||
|
||||
return 'unserialize(' .
|
||||
\var_export(\serialize($variable), true) .
|
||||
')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function arrayOnlyContainsScalars(array $array)
|
||||
{
|
||||
$result = true;
|
||||
|
||||
foreach ($array as $element) {
|
||||
if (\is_array($element)) {
|
||||
$result = self::arrayOnlyContainsScalars($element);
|
||||
} elseif (!\is_scalar($element) && null !== $element) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
42
vendor/phpunit/phpunit/src/Util/InvalidArgumentHelper.php
vendored
Normal file
42
vendor/phpunit/phpunit/src/Util/InvalidArgumentHelper.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Factory for PHPUnit\Framework\Exception objects that are used to describe
|
||||
* invalid arguments passed to a function or method.
|
||||
*/
|
||||
class InvalidArgumentHelper
|
||||
{
|
||||
/**
|
||||
* @param int $argument
|
||||
* @param string $type
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return Exception
|
||||
*/
|
||||
public static function factory($argument, $type, $value = null)
|
||||
{
|
||||
$stack = \debug_backtrace();
|
||||
|
||||
return new Exception(
|
||||
\sprintf(
|
||||
'Argument #%d%sof %s::%s() must be a %s',
|
||||
$argument,
|
||||
$value !== null ? ' (' . \gettype($value) . '#' . $value . ')' : ' (No Value) ',
|
||||
$stack[1]['class'],
|
||||
$stack[1]['function'],
|
||||
$type
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
78
vendor/phpunit/phpunit/src/Util/Json.php
vendored
Normal file
78
vendor/phpunit/phpunit/src/Util/Json.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
class Json
|
||||
{
|
||||
/**
|
||||
* Prettify json string
|
||||
*
|
||||
* @param string $json
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
*/
|
||||
public static function prettify(string $json)
|
||||
{
|
||||
$decodedJson = \json_decode($json, true);
|
||||
|
||||
if (\json_last_error()) {
|
||||
throw new Exception(
|
||||
'Cannot prettify invalid json'
|
||||
);
|
||||
}
|
||||
|
||||
return \json_encode($decodedJson, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
/*
|
||||
* To allow comparison of JSON strings, first process them into a consistent
|
||||
* format so that they can be compared as strings.
|
||||
* @return array ($error, $canonicalized_json) The $error parameter is used
|
||||
* to indicate an error decoding the json. This is used to avoid ambiguity
|
||||
* with JSON strings consisting entirely of 'null' or 'false'.
|
||||
*/
|
||||
public static function canonicalize(string $json)
|
||||
{
|
||||
$decodedJson = \json_decode($json, true);
|
||||
|
||||
if (\json_last_error()) {
|
||||
return [true, null];
|
||||
}
|
||||
|
||||
self::recursiveSort($decodedJson);
|
||||
|
||||
$reencodedJson = \json_encode($decodedJson);
|
||||
|
||||
return [false, $reencodedJson];
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON object keys are unordered while PHP array keys are ordered.
|
||||
* Sort all array keys to ensure both the expected and actual values have
|
||||
* their keys in the same order.
|
||||
*/
|
||||
private static function recursiveSort(&$json)
|
||||
{
|
||||
if (false === \is_array($json)) {
|
||||
return;
|
||||
}
|
||||
|
||||
\ksort($json);
|
||||
|
||||
foreach ($json as $key => &$value) {
|
||||
self::recursiveSort($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
450
vendor/phpunit/phpunit/src/Util/Log/JUnit.php
vendored
Normal file
450
vendor/phpunit/phpunit/src/Util/Log/JUnit.php
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\Log;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\ExceptionWrapper;
|
||||
use PHPUnit\Framework\SelfDescribing;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestFailure;
|
||||
use PHPUnit\Framework\TestListener;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\Util\Filter;
|
||||
use PHPUnit\Util\Printer;
|
||||
use PHPUnit\Util\Xml;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
* A TestListener that generates a logfile of the test execution in XML markup.
|
||||
*
|
||||
* The XML markup used is the same as the one that is used by the JUnit Ant task.
|
||||
*/
|
||||
class JUnit extends Printer implements TestListener
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $document;
|
||||
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
protected $root;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $reportUselessTests = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $writeDocument = true;
|
||||
|
||||
/**
|
||||
* @var DOMElement[]
|
||||
*/
|
||||
protected $testSuites = [];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteTests = [0];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteAssertions = [0];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteErrors = [0];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteFailures = [0];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteSkipped = [0];
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $testSuiteTimes = [0];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $testSuiteLevel = 0;
|
||||
|
||||
/**
|
||||
* @var ?DOMElement
|
||||
*/
|
||||
protected $currentTestCase;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $out
|
||||
* @param bool $reportUselessTests
|
||||
*/
|
||||
public function __construct($out = null, $reportUselessTests = false)
|
||||
{
|
||||
$this->document = new DOMDocument('1.0', 'UTF-8');
|
||||
$this->document->formatOutput = true;
|
||||
|
||||
$this->root = $this->document->createElement('testsuites');
|
||||
$this->document->appendChild($this->root);
|
||||
|
||||
parent::__construct($out);
|
||||
|
||||
$this->reportUselessTests = $reportUselessTests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer and close output.
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if ($this->writeDocument === true) {
|
||||
$this->write($this->getXML());
|
||||
}
|
||||
|
||||
parent::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* An error occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addError(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->doAddFault($test, $e, $time, 'error');
|
||||
$this->testSuiteErrors[$this->testSuiteLevel]++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param Warning $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addWarning(Test $test, Warning $e, $time)
|
||||
{
|
||||
$this->doAddFault($test, $e, $time, 'warning');
|
||||
$this->testSuiteFailures[$this->testSuiteLevel]++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A failure occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param AssertionFailedError $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addFailure(Test $test, AssertionFailedError $e, $time)
|
||||
{
|
||||
$this->doAddFault($test, $e, $time, 'failure');
|
||||
$this->testSuiteFailures[$this->testSuiteLevel]++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Incomplete test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addIncompleteTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->doAddSkipped($test);
|
||||
}
|
||||
|
||||
/**
|
||||
* Risky test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addRiskyTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
if (!$this->reportUselessTests || $this->currentTestCase === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$error = $this->document->createElement(
|
||||
'error',
|
||||
Xml::prepareString(
|
||||
"Risky Test\n" .
|
||||
Filter::getFilteredStacktrace($e)
|
||||
)
|
||||
);
|
||||
|
||||
$error->setAttribute('type', \get_class($e));
|
||||
|
||||
$this->currentTestCase->appendChild($error);
|
||||
|
||||
$this->testSuiteErrors[$this->testSuiteLevel]++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skipped test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addSkippedTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->doAddSkipped($test);
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite started.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function startTestSuite(TestSuite $suite)
|
||||
{
|
||||
$testSuite = $this->document->createElement('testsuite');
|
||||
$testSuite->setAttribute('name', $suite->getName());
|
||||
|
||||
if (\class_exists($suite->getName(), false)) {
|
||||
try {
|
||||
$class = new ReflectionClass($suite->getName());
|
||||
|
||||
$testSuite->setAttribute('file', $class->getFileName());
|
||||
} catch (ReflectionException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->testSuiteLevel > 0) {
|
||||
$this->testSuites[$this->testSuiteLevel]->appendChild($testSuite);
|
||||
} else {
|
||||
$this->root->appendChild($testSuite);
|
||||
}
|
||||
|
||||
$this->testSuiteLevel++;
|
||||
$this->testSuites[$this->testSuiteLevel] = $testSuite;
|
||||
$this->testSuiteTests[$this->testSuiteLevel] = 0;
|
||||
$this->testSuiteAssertions[$this->testSuiteLevel] = 0;
|
||||
$this->testSuiteErrors[$this->testSuiteLevel] = 0;
|
||||
$this->testSuiteFailures[$this->testSuiteLevel] = 0;
|
||||
$this->testSuiteSkipped[$this->testSuiteLevel] = 0;
|
||||
$this->testSuiteTimes[$this->testSuiteLevel] = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite ended.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function endTestSuite(TestSuite $suite)
|
||||
{
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'tests',
|
||||
$this->testSuiteTests[$this->testSuiteLevel]
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'assertions',
|
||||
$this->testSuiteAssertions[$this->testSuiteLevel]
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'errors',
|
||||
$this->testSuiteErrors[$this->testSuiteLevel]
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'failures',
|
||||
$this->testSuiteFailures[$this->testSuiteLevel]
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'skipped',
|
||||
$this->testSuiteSkipped[$this->testSuiteLevel]
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->setAttribute(
|
||||
'time',
|
||||
\sprintf('%F', $this->testSuiteTimes[$this->testSuiteLevel])
|
||||
);
|
||||
|
||||
if ($this->testSuiteLevel > 1) {
|
||||
$this->testSuiteTests[$this->testSuiteLevel - 1] += $this->testSuiteTests[$this->testSuiteLevel];
|
||||
$this->testSuiteAssertions[$this->testSuiteLevel - 1] += $this->testSuiteAssertions[$this->testSuiteLevel];
|
||||
$this->testSuiteErrors[$this->testSuiteLevel - 1] += $this->testSuiteErrors[$this->testSuiteLevel];
|
||||
$this->testSuiteFailures[$this->testSuiteLevel - 1] += $this->testSuiteFailures[$this->testSuiteLevel];
|
||||
$this->testSuiteSkipped[$this->testSuiteLevel - 1] += $this->testSuiteSkipped[$this->testSuiteLevel];
|
||||
$this->testSuiteTimes[$this->testSuiteLevel - 1] += $this->testSuiteTimes[$this->testSuiteLevel];
|
||||
}
|
||||
|
||||
$this->testSuiteLevel--;
|
||||
}
|
||||
|
||||
/**
|
||||
* A test started.
|
||||
*
|
||||
* @param Test $test
|
||||
*/
|
||||
public function startTest(Test $test)
|
||||
{
|
||||
$testCase = $this->document->createElement('testcase');
|
||||
$testCase->setAttribute('name', $test->getName());
|
||||
|
||||
if ($test instanceof TestCase) {
|
||||
$class = new ReflectionClass($test);
|
||||
$methodName = $test->getName(!$test->usesDataProvider());
|
||||
|
||||
if ($class->hasMethod($methodName)) {
|
||||
$method = $class->getMethod($methodName);
|
||||
|
||||
$testCase->setAttribute('class', $class->getName());
|
||||
$testCase->setAttribute('classname', \str_replace('\\', '.', $class->getName()));
|
||||
$testCase->setAttribute('file', $class->getFileName());
|
||||
$testCase->setAttribute('line', $method->getStartLine());
|
||||
}
|
||||
}
|
||||
|
||||
$this->currentTestCase = $testCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* A test ended.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param float $time
|
||||
*/
|
||||
public function endTest(Test $test, $time)
|
||||
{
|
||||
if ($test instanceof TestCase) {
|
||||
$numAssertions = $test->getNumAssertions();
|
||||
$this->testSuiteAssertions[$this->testSuiteLevel] += $numAssertions;
|
||||
|
||||
$this->currentTestCase->setAttribute(
|
||||
'assertions',
|
||||
$numAssertions
|
||||
);
|
||||
}
|
||||
|
||||
$this->currentTestCase->setAttribute(
|
||||
'time',
|
||||
\sprintf('%F', $time)
|
||||
);
|
||||
|
||||
$this->testSuites[$this->testSuiteLevel]->appendChild(
|
||||
$this->currentTestCase
|
||||
);
|
||||
|
||||
$this->testSuiteTests[$this->testSuiteLevel]++;
|
||||
$this->testSuiteTimes[$this->testSuiteLevel] += $time;
|
||||
|
||||
if (\method_exists($test, 'hasOutput') && $test->hasOutput()) {
|
||||
$systemOut = $this->document->createElement(
|
||||
'system-out',
|
||||
Xml::prepareString($test->getActualOutput())
|
||||
);
|
||||
|
||||
$this->currentTestCase->appendChild($systemOut);
|
||||
}
|
||||
|
||||
$this->currentTestCase = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXML()
|
||||
{
|
||||
return $this->document->saveXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables the writing of the document
|
||||
* in flush().
|
||||
*
|
||||
* This is a "hack" needed for the integration of
|
||||
* PHPUnit with Phing.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setWriteDocument($flag)
|
||||
{
|
||||
if (\is_bool($flag)) {
|
||||
$this->writeDocument = $flag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which generalizes addError() and addFailure()
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
* @param string $type
|
||||
*/
|
||||
private function doAddFault(Test $test, \Exception $e, $time, $type)
|
||||
{
|
||||
if ($this->currentTestCase === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($test instanceof SelfDescribing) {
|
||||
$buffer = $test->toString() . "\n";
|
||||
} else {
|
||||
$buffer = '';
|
||||
}
|
||||
|
||||
$buffer .= TestFailure::exceptionToString($e) . "\n" .
|
||||
Filter::getFilteredStacktrace($e);
|
||||
|
||||
$fault = $this->document->createElement(
|
||||
$type,
|
||||
Xml::prepareString($buffer)
|
||||
);
|
||||
|
||||
if ($e instanceof ExceptionWrapper) {
|
||||
$fault->setAttribute('type', $e->getClassName());
|
||||
} else {
|
||||
$fault->setAttribute('type', \get_class($e));
|
||||
}
|
||||
|
||||
$this->currentTestCase->appendChild($fault);
|
||||
}
|
||||
|
||||
private function doAddSkipped(Test $test)
|
||||
{
|
||||
if ($this->currentTestCase === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$skipped = $this->document->createElement('skipped');
|
||||
$this->currentTestCase->appendChild($skipped);
|
||||
|
||||
$this->testSuiteSkipped[$this->testSuiteLevel]++;
|
||||
}
|
||||
}
|
||||
423
vendor/phpunit/phpunit/src/Util/Log/TeamCity.php
vendored
Normal file
423
vendor/phpunit/phpunit/src/Util/Log/TeamCity.php
vendored
Normal file
@@ -0,0 +1,423 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util\Log;
|
||||
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\ExceptionWrapper;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestFailure;
|
||||
use PHPUnit\Framework\TestResult;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\TextUI\ResultPrinter;
|
||||
use PHPUnit\Util\Filter;
|
||||
use ReflectionClass;
|
||||
use SebastianBergmann\Comparator\ComparisonFailure;
|
||||
|
||||
/**
|
||||
* A TestListener that generates a logfile of the test execution using the
|
||||
* TeamCity format (for use with PhpStorm, for instance).
|
||||
*/
|
||||
class TeamCity extends ResultPrinter
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isSummaryTestCountPrinted = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $startedTestName;
|
||||
|
||||
/**
|
||||
* @var int|false
|
||||
*/
|
||||
private $flowId;
|
||||
|
||||
/**
|
||||
* @param string $progress
|
||||
*/
|
||||
protected function writeProgress($progress)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TestResult $result
|
||||
*/
|
||||
public function printResult(TestResult $result)
|
||||
{
|
||||
$this->printHeader();
|
||||
$this->printFooter($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* An error occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addError(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->printEvent(
|
||||
'testFailed',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param Warning $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addWarning(Test $test, Warning $e, $time)
|
||||
{
|
||||
$this->printEvent(
|
||||
'testFailed',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A failure occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param AssertionFailedError $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addFailure(Test $test, AssertionFailedError $e, $time)
|
||||
{
|
||||
$parameters = [
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
];
|
||||
|
||||
if ($e instanceof ExpectationFailedException) {
|
||||
$comparisonFailure = $e->getComparisonFailure();
|
||||
|
||||
if ($comparisonFailure instanceof ComparisonFailure) {
|
||||
$expectedString = $comparisonFailure->getExpectedAsString();
|
||||
|
||||
if (null === $expectedString || empty($expectedString)) {
|
||||
$expectedString = self::getPrimitiveValueAsString($comparisonFailure->getExpected());
|
||||
}
|
||||
|
||||
$actualString = $comparisonFailure->getActualAsString();
|
||||
|
||||
if (null === $actualString || empty($actualString)) {
|
||||
$actualString = self::getPrimitiveValueAsString($comparisonFailure->getActual());
|
||||
}
|
||||
|
||||
if (null !== $actualString && null !== $expectedString) {
|
||||
$parameters['type'] = 'comparisonFailure';
|
||||
$parameters['actual'] = $actualString;
|
||||
$parameters['expected'] = $expectedString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->printEvent('testFailed', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Incomplete test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addIncompleteTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->printIgnoredTest($test->getName(), $e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Risky test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addRiskyTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->addError($test, $e, $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Skipped test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addSkippedTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$testName = $test->getName();
|
||||
if ($this->startedTestName != $testName) {
|
||||
$this->startTest($test);
|
||||
$this->printIgnoredTest($testName, $e);
|
||||
$this->endTest($test, $time);
|
||||
} else {
|
||||
$this->printIgnoredTest($testName, $e);
|
||||
}
|
||||
}
|
||||
|
||||
public function printIgnoredTest($testName, \Exception $e)
|
||||
{
|
||||
$this->printEvent(
|
||||
'testIgnored',
|
||||
[
|
||||
'name' => $testName,
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite started.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function startTestSuite(TestSuite $suite)
|
||||
{
|
||||
if (\stripos(\ini_get('disable_functions'), 'getmypid') === false) {
|
||||
$this->flowId = \getmypid();
|
||||
} else {
|
||||
$this->flowId = false;
|
||||
}
|
||||
|
||||
if (!$this->isSummaryTestCountPrinted) {
|
||||
$this->isSummaryTestCountPrinted = true;
|
||||
|
||||
$this->printEvent(
|
||||
'testCount',
|
||||
['count' => \count($suite)]
|
||||
);
|
||||
}
|
||||
|
||||
$suiteName = $suite->getName();
|
||||
|
||||
if (empty($suiteName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parameters = ['name' => $suiteName];
|
||||
|
||||
if (\class_exists($suiteName, false)) {
|
||||
$fileName = self::getFileName($suiteName);
|
||||
$parameters['locationHint'] = "php_qn://$fileName::\\$suiteName";
|
||||
} else {
|
||||
$split = \preg_split('/::/', $suiteName);
|
||||
|
||||
if (\count($split) == 2 && \method_exists($split[0], $split[1])) {
|
||||
$fileName = self::getFileName($split[0]);
|
||||
$parameters['locationHint'] = "php_qn://$fileName::\\$suiteName";
|
||||
$parameters['name'] = $split[1];
|
||||
}
|
||||
}
|
||||
|
||||
$this->printEvent('testSuiteStarted', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite ended.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function endTestSuite(TestSuite $suite)
|
||||
{
|
||||
$suiteName = $suite->getName();
|
||||
|
||||
if (empty($suiteName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parameters = ['name' => $suiteName];
|
||||
|
||||
if (!\class_exists($suiteName, false)) {
|
||||
$split = \preg_split('/::/', $suiteName);
|
||||
|
||||
if (\count($split) == 2 && \method_exists($split[0], $split[1])) {
|
||||
$parameters['name'] = $split[1];
|
||||
}
|
||||
}
|
||||
|
||||
$this->printEvent('testSuiteFinished', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* A test started.
|
||||
*
|
||||
* @param Test $test
|
||||
*/
|
||||
public function startTest(Test $test)
|
||||
{
|
||||
$testName = $test->getName();
|
||||
$this->startedTestName = $testName;
|
||||
$params = ['name' => $testName];
|
||||
|
||||
if ($test instanceof TestCase) {
|
||||
$className = \get_class($test);
|
||||
$fileName = self::getFileName($className);
|
||||
$params['locationHint'] = "php_qn://$fileName::\\$className::$testName";
|
||||
}
|
||||
|
||||
$this->printEvent('testStarted', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* A test ended.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param float $time
|
||||
*/
|
||||
public function endTest(Test $test, $time)
|
||||
{
|
||||
parent::endTest($test, $time);
|
||||
|
||||
$this->printEvent(
|
||||
'testFinished',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'duration' => (int) (\round($time, 2) * 1000)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $eventName
|
||||
* @param array $params
|
||||
*/
|
||||
private function printEvent($eventName, $params = [])
|
||||
{
|
||||
$this->write("\n##teamcity[$eventName");
|
||||
|
||||
if ($this->flowId) {
|
||||
$params['flowId'] = $this->flowId;
|
||||
}
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$escapedValue = self::escapeValue($value);
|
||||
$this->write(" $key='$escapedValue'");
|
||||
}
|
||||
|
||||
$this->write("]\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getMessage(\Exception $e)
|
||||
{
|
||||
$message = '';
|
||||
|
||||
if ($e instanceof ExceptionWrapper) {
|
||||
if (\strlen($e->getClassName()) != 0) {
|
||||
$message .= $e->getClassName();
|
||||
}
|
||||
|
||||
if (\strlen($message) != 0 && \strlen($e->getMessage()) != 0) {
|
||||
$message .= ' : ';
|
||||
}
|
||||
}
|
||||
|
||||
return $message . $e->getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getDetails(\Exception $e)
|
||||
{
|
||||
$stackTrace = Filter::getFilteredStacktrace($e);
|
||||
$previous = $e instanceof ExceptionWrapper ?
|
||||
$e->getPreviousWrapped() : $e->getPrevious();
|
||||
|
||||
while ($previous) {
|
||||
$stackTrace .= "\nCaused by\n" .
|
||||
TestFailure::exceptionToString($previous) . "\n" .
|
||||
Filter::getFilteredStacktrace($previous);
|
||||
|
||||
$previous = $previous instanceof ExceptionWrapper ?
|
||||
$previous->getPreviousWrapped() : $previous->getPrevious();
|
||||
}
|
||||
|
||||
return ' ' . \str_replace("\n", "\n ", $stackTrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getPrimitiveValueAsString($value)
|
||||
{
|
||||
if (null === $value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (\is_bool($value)) {
|
||||
return $value == true ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (\is_scalar($value)) {
|
||||
return \print_r($value, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function escapeValue($text)
|
||||
{
|
||||
$text = \str_replace('|', '||', $text);
|
||||
$text = \str_replace("'", "|'", $text);
|
||||
$text = \str_replace("\n", '|n', $text);
|
||||
$text = \str_replace("\r", '|r', $text);
|
||||
$text = \str_replace(']', '|]', $text);
|
||||
$text = \str_replace('[', '|[', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getFileName($className)
|
||||
{
|
||||
$reflectionClass = new ReflectionClass($className);
|
||||
|
||||
return $reflectionClass->getFileName();
|
||||
}
|
||||
}
|
||||
421
vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php
vendored
Normal file
421
vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php
vendored
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util\PHP;
|
||||
|
||||
use __PHP_Incomplete_Class;
|
||||
use ErrorException;
|
||||
use PHPUnit\Framework\Exception;
|
||||
use PHPUnit\Framework\SyntheticError;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestFailure;
|
||||
use PHPUnit\Framework\TestResult;
|
||||
use PHPUnit\Util\InvalidArgumentHelper;
|
||||
use SebastianBergmann\Environment\Runtime;
|
||||
|
||||
/**
|
||||
* Utility methods for PHP sub-processes.
|
||||
*/
|
||||
abstract class AbstractPhpProcess
|
||||
{
|
||||
/**
|
||||
* @var Runtime
|
||||
*/
|
||||
protected $runtime;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $stderrRedirection = false;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $stdin = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $args = '';
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $env = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $timeout = 0;
|
||||
|
||||
/**
|
||||
* Creates internal Runtime instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->runtime = new Runtime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines if should use STDERR redirection or not.
|
||||
*
|
||||
* Then $stderrRedirection is TRUE, STDERR is redirected to STDOUT.
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @param bool $stderrRedirection
|
||||
*/
|
||||
public function setUseStderrRedirection($stderrRedirection)
|
||||
{
|
||||
if (!\is_bool($stderrRedirection)) {
|
||||
throw InvalidArgumentHelper::factory(1, 'boolean');
|
||||
}
|
||||
|
||||
$this->stderrRedirection = $stderrRedirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if uses STDERR redirection or FALSE if not.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function useStderrRedirection()
|
||||
{
|
||||
return $this->stderrRedirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input string to be sent via STDIN
|
||||
*
|
||||
* @param string $stdin
|
||||
*/
|
||||
public function setStdin($stdin)
|
||||
{
|
||||
$this->stdin = (string) $stdin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input string to be sent via STDIN
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStdin()
|
||||
{
|
||||
return $this->stdin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the string of arguments to pass to the php job
|
||||
*
|
||||
* @param string $args
|
||||
*/
|
||||
public function setArgs($args)
|
||||
{
|
||||
$this->args = (string) $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string of arguments to pass to the php job
|
||||
*
|
||||
* @retrun string
|
||||
*/
|
||||
public function getArgs()
|
||||
{
|
||||
return $this->args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the array of environment variables to start the child process with
|
||||
*
|
||||
* @param array<string, string> $env
|
||||
*/
|
||||
public function setEnv(array $env)
|
||||
{
|
||||
$this->env = $env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the array of environment variables to start the child process with
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getEnv()
|
||||
{
|
||||
return $this->env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount of seconds to wait before timing out
|
||||
*
|
||||
* @param int $timeout
|
||||
*/
|
||||
public function setTimeout($timeout)
|
||||
{
|
||||
$this->timeout = (int) $timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of seconds to wait before timing out
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimeout()
|
||||
{
|
||||
return $this->timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractPhpProcess
|
||||
*/
|
||||
public static function factory()
|
||||
{
|
||||
if (DIRECTORY_SEPARATOR == '\\') {
|
||||
return new WindowsPhpProcess;
|
||||
}
|
||||
|
||||
return new DefaultPhpProcess;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a single test in a separate PHP process.
|
||||
*
|
||||
* @param string $job
|
||||
* @param Test $test
|
||||
* @param TestResult $result
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function runTestJob($job, Test $test, TestResult $result)
|
||||
{
|
||||
$result->startTest($test);
|
||||
|
||||
$_result = $this->runJob($job);
|
||||
|
||||
$this->processChildResult(
|
||||
$test,
|
||||
$result,
|
||||
$_result['stdout'],
|
||||
$_result['stderr']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command based into the configurations.
|
||||
*
|
||||
* @param array $settings
|
||||
* @param string|null $file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommand(array $settings, $file = null)
|
||||
{
|
||||
$command = $this->runtime->getBinary();
|
||||
$command .= $this->settingsToParameters($settings);
|
||||
|
||||
if ('phpdbg' === PHP_SAPI) {
|
||||
$command .= ' -qrr ';
|
||||
|
||||
if ($file) {
|
||||
$command .= '-e ' . \escapeshellarg($file);
|
||||
} else {
|
||||
$command .= \escapeshellarg(__DIR__ . '/eval-stdin.php');
|
||||
}
|
||||
} elseif ($file) {
|
||||
$command .= ' -f ' . \escapeshellarg($file);
|
||||
}
|
||||
|
||||
if ($this->args) {
|
||||
$command .= ' -- ' . $this->args;
|
||||
}
|
||||
|
||||
if (true === $this->stderrRedirection) {
|
||||
$command .= ' 2>&1';
|
||||
}
|
||||
|
||||
return $command;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a single job (PHP code) using a separate PHP process.
|
||||
*
|
||||
* @param string $job
|
||||
* @param array $settings
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
abstract public function runJob($job, array $settings = []);
|
||||
|
||||
/**
|
||||
* @param array $settings
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function settingsToParameters(array $settings)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
foreach ($settings as $setting) {
|
||||
$buffer .= ' -d ' . \escapeshellarg($setting);
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the TestResult object from an isolated process.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param TestResult $result
|
||||
* @param string $stdout
|
||||
* @param string $stderr
|
||||
*/
|
||||
private function processChildResult(Test $test, TestResult $result, $stdout, $stderr)
|
||||
{
|
||||
$time = 0;
|
||||
|
||||
if (!empty($stderr)) {
|
||||
$result->addError(
|
||||
$test,
|
||||
new Exception(\trim($stderr)),
|
||||
$time
|
||||
);
|
||||
} else {
|
||||
\set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
|
||||
});
|
||||
|
||||
try {
|
||||
if (\strpos($stdout, "#!/usr/bin/env php\n") === 0) {
|
||||
$stdout = \substr($stdout, 19);
|
||||
}
|
||||
|
||||
$childResult = \unserialize(\str_replace("#!/usr/bin/env php\n", '', $stdout));
|
||||
\restore_error_handler();
|
||||
} catch (ErrorException $e) {
|
||||
\restore_error_handler();
|
||||
$childResult = false;
|
||||
|
||||
$result->addError(
|
||||
$test,
|
||||
new Exception(\trim($stdout), 0, $e),
|
||||
$time
|
||||
);
|
||||
}
|
||||
|
||||
if ($childResult !== false) {
|
||||
if (!empty($childResult['output'])) {
|
||||
$output = $childResult['output'];
|
||||
}
|
||||
|
||||
$test->setResult($childResult['testResult']);
|
||||
$test->addToAssertionCount($childResult['numAssertions']);
|
||||
|
||||
/** @var TestResult $childResult */
|
||||
$childResult = $childResult['result'];
|
||||
|
||||
if ($result->getCollectCodeCoverageInformation()) {
|
||||
$result->getCodeCoverage()->merge(
|
||||
$childResult->getCodeCoverage()
|
||||
);
|
||||
}
|
||||
|
||||
$time = $childResult->time();
|
||||
$notImplemented = $childResult->notImplemented();
|
||||
$risky = $childResult->risky();
|
||||
$skipped = $childResult->skipped();
|
||||
$errors = $childResult->errors();
|
||||
$warnings = $childResult->warnings();
|
||||
$failures = $childResult->failures();
|
||||
|
||||
if (!empty($notImplemented)) {
|
||||
$result->addError(
|
||||
$test,
|
||||
$this->getException($notImplemented[0]),
|
||||
$time
|
||||
);
|
||||
} elseif (!empty($risky)) {
|
||||
$result->addError(
|
||||
$test,
|
||||
$this->getException($risky[0]),
|
||||
$time
|
||||
);
|
||||
} elseif (!empty($skipped)) {
|
||||
$result->addError(
|
||||
$test,
|
||||
$this->getException($skipped[0]),
|
||||
$time
|
||||
);
|
||||
} elseif (!empty($errors)) {
|
||||
$result->addError(
|
||||
$test,
|
||||
$this->getException($errors[0]),
|
||||
$time
|
||||
);
|
||||
} elseif (!empty($warnings)) {
|
||||
$result->addWarning(
|
||||
$test,
|
||||
$this->getException($warnings[0]),
|
||||
$time
|
||||
);
|
||||
} elseif (!empty($failures)) {
|
||||
$result->addFailure(
|
||||
$test,
|
||||
$this->getException($failures[0]),
|
||||
$time
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result->endTest($test, $time);
|
||||
|
||||
if (!empty($output)) {
|
||||
print $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the thrown exception from a PHPUnit\Framework\TestFailure.
|
||||
*
|
||||
* @param TestFailure $error
|
||||
*
|
||||
* @return Exception
|
||||
*
|
||||
* @see https://github.com/sebastianbergmann/phpunit/issues/74
|
||||
*/
|
||||
private function getException(TestFailure $error)
|
||||
{
|
||||
$exception = $error->thrownException();
|
||||
|
||||
if ($exception instanceof __PHP_Incomplete_Class) {
|
||||
$exceptionArray = [];
|
||||
foreach ((array) $exception as $key => $value) {
|
||||
$key = \substr($key, \strrpos($key, "\0") + 1);
|
||||
$exceptionArray[$key] = $value;
|
||||
}
|
||||
|
||||
$exception = new SyntheticError(
|
||||
\sprintf(
|
||||
'%s: %s',
|
||||
$exceptionArray['_PHP_Incomplete_Class_Name'],
|
||||
$exceptionArray['message']
|
||||
),
|
||||
$exceptionArray['code'],
|
||||
$exceptionArray['file'],
|
||||
$exceptionArray['line'],
|
||||
$exceptionArray['trace']
|
||||
);
|
||||
}
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
232
vendor/phpunit/phpunit/src/Util/PHP/DefaultPhpProcess.php
vendored
Normal file
232
vendor/phpunit/phpunit/src/Util/PHP/DefaultPhpProcess.php
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\PHP;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Default utility for PHP sub-processes.
|
||||
*/
|
||||
class DefaultPhpProcess extends AbstractPhpProcess
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFile;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $useTempFile = false;
|
||||
|
||||
/**
|
||||
* Runs a single job (PHP code) using a separate PHP process.
|
||||
*
|
||||
* @param string $job
|
||||
* @param array $settings
|
||||
*
|
||||
* @return array<string, string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function runJob($job, array $settings = [])
|
||||
{
|
||||
if ($this->useTempFile || $this->stdin) {
|
||||
if (!($this->tempFile = \tempnam(\sys_get_temp_dir(), 'PHPUnit')) ||
|
||||
\file_put_contents($this->tempFile, $job) === false) {
|
||||
throw new Exception(
|
||||
'Unable to write temporary file'
|
||||
);
|
||||
}
|
||||
|
||||
$job = $this->stdin;
|
||||
}
|
||||
|
||||
return $this->runProcess($job, $settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of file handles to be used in place of pipes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getHandles()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles creating the child process and returning the STDOUT and STDERR
|
||||
*
|
||||
* @param string $job
|
||||
* @param array $settings
|
||||
*
|
||||
* @return array<string, string>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function runProcess($job, $settings)
|
||||
{
|
||||
$handles = $this->getHandles();
|
||||
|
||||
$env = null;
|
||||
|
||||
if ($this->env) {
|
||||
$env = $_SERVER ?? [];
|
||||
unset($env['argv'], $env['argc']);
|
||||
$env = \array_merge($env, $this->env);
|
||||
|
||||
foreach ($env as $envKey => $envVar) {
|
||||
if (\is_array($envVar)) {
|
||||
unset($env[$envKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pipeSpec = [
|
||||
0 => $handles[0] ?? ['pipe', 'r'],
|
||||
1 => $handles[1] ?? ['pipe', 'w'],
|
||||
2 => $handles[2] ?? ['pipe', 'w'],
|
||||
];
|
||||
|
||||
$process = \proc_open(
|
||||
$this->getCommand($settings, $this->tempFile),
|
||||
$pipeSpec,
|
||||
$pipes,
|
||||
null,
|
||||
$env
|
||||
);
|
||||
|
||||
if (!\is_resource($process)) {
|
||||
throw new Exception(
|
||||
'Unable to spawn worker process'
|
||||
);
|
||||
}
|
||||
|
||||
if ($job) {
|
||||
$this->process($pipes[0], $job);
|
||||
}
|
||||
|
||||
\fclose($pipes[0]);
|
||||
|
||||
if ($this->timeout) {
|
||||
$stderr = $stdout = '';
|
||||
|
||||
unset($pipes[0]);
|
||||
|
||||
while (true) {
|
||||
$r = $pipes;
|
||||
$w = null;
|
||||
$e = null;
|
||||
|
||||
$n = @\stream_select($r, $w, $e, $this->timeout);
|
||||
|
||||
if ($n === false) {
|
||||
break;
|
||||
} elseif ($n === 0) {
|
||||
\proc_terminate($process, 9);
|
||||
|
||||
throw new Exception(
|
||||
\sprintf(
|
||||
'Job execution aborted after %d seconds',
|
||||
$this->timeout
|
||||
)
|
||||
);
|
||||
} elseif ($n > 0) {
|
||||
foreach ($r as $pipe) {
|
||||
$pipeOffset = 0;
|
||||
|
||||
foreach ($pipes as $i => $origPipe) {
|
||||
if ($pipe == $origPipe) {
|
||||
$pipeOffset = $i;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$pipeOffset) {
|
||||
break;
|
||||
}
|
||||
|
||||
$line = \fread($pipe, 8192);
|
||||
|
||||
if (\strlen($line) == 0) {
|
||||
\fclose($pipes[$pipeOffset]);
|
||||
|
||||
unset($pipes[$pipeOffset]);
|
||||
} else {
|
||||
if ($pipeOffset == 1) {
|
||||
$stdout .= $line;
|
||||
} else {
|
||||
$stderr .= $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pipes)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($pipes[1])) {
|
||||
$stdout = \stream_get_contents($pipes[1]);
|
||||
|
||||
\fclose($pipes[1]);
|
||||
}
|
||||
|
||||
if (isset($pipes[2])) {
|
||||
$stderr = \stream_get_contents($pipes[2]);
|
||||
|
||||
\fclose($pipes[2]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($handles[1])) {
|
||||
\rewind($handles[1]);
|
||||
|
||||
$stdout = \stream_get_contents($handles[1]);
|
||||
|
||||
\fclose($handles[1]);
|
||||
}
|
||||
|
||||
if (isset($handles[2])) {
|
||||
\rewind($handles[2]);
|
||||
|
||||
$stderr = \stream_get_contents($handles[2]);
|
||||
|
||||
\fclose($handles[2]);
|
||||
}
|
||||
|
||||
\proc_close($process);
|
||||
|
||||
$this->cleanup();
|
||||
|
||||
return ['stdout' => $stdout, 'stderr' => $stderr];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $pipe
|
||||
* @param string $job
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function process($pipe, $job)
|
||||
{
|
||||
\fwrite($pipe, $job);
|
||||
}
|
||||
|
||||
protected function cleanup()
|
||||
{
|
||||
if ($this->tempFile) {
|
||||
\unlink($this->tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
vendor/phpunit/phpunit/src/Util/PHP/Template/PhptTestCase.tpl.dist
vendored
Normal file
46
vendor/phpunit/phpunit/src/Util/PHP/Template/PhptTestCase.tpl.dist
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
|
||||
$composerAutoload = {composerAutoload};
|
||||
$phar = {phar};
|
||||
$autoPrependFile = {autoPrependFile};
|
||||
|
||||
ob_start();
|
||||
|
||||
$GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST'][] = '{job}';
|
||||
|
||||
if ($composerAutoload) {
|
||||
require_once $composerAutoload;
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload);
|
||||
} else if ($phar) {
|
||||
require $phar;
|
||||
}
|
||||
|
||||
{globals}
|
||||
$coverage = null;
|
||||
|
||||
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
|
||||
require_once $GLOBALS['__PHPUNIT_BOOTSTRAP'];
|
||||
}
|
||||
|
||||
if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
||||
$coverage = new CodeCoverage(null);
|
||||
$coverage->start(__FILE__);
|
||||
}
|
||||
|
||||
register_shutdown_function(function() use ($coverage, $autoPrependFile) {
|
||||
$output = null;
|
||||
if ($coverage) {
|
||||
$output = $coverage->stop();
|
||||
}
|
||||
file_put_contents('{coverageFile}', serialize($output));
|
||||
});
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
if ($autoPrependFile) {
|
||||
require $autoPrependFile;
|
||||
$includes = get_included_files();
|
||||
$GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST'][] = array_pop($includes);
|
||||
unset($includes);
|
||||
}
|
||||
107
vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseClass.tpl.dist
vendored
Normal file
107
vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseClass.tpl.dist
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
|
||||
if (!defined('STDOUT')) {
|
||||
// php://stdout does not obey output buffering. Any output would break
|
||||
// unserialization of child process results in the parent process.
|
||||
define('STDOUT', fopen('php://temp', 'w+b'));
|
||||
define('STDERR', fopen('php://stderr', 'wb'));
|
||||
}
|
||||
|
||||
{iniSettings}
|
||||
ini_set('display_errors', 'stderr');
|
||||
set_include_path('{include_path}');
|
||||
|
||||
$composerAutoload = {composerAutoload};
|
||||
$phar = {phar};
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($composerAutoload) {
|
||||
require_once $composerAutoload;
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload);
|
||||
} else if ($phar) {
|
||||
require $phar;
|
||||
}
|
||||
|
||||
function __phpunit_run_isolated_test()
|
||||
{
|
||||
if (!class_exists('{className}')) {
|
||||
require_once '{filename}';
|
||||
}
|
||||
|
||||
$result = new PHPUnit\Framework\TestResult;
|
||||
|
||||
if ({collectCodeCoverageInformation}) {
|
||||
$result->setCodeCoverage(
|
||||
new CodeCoverage(
|
||||
null,
|
||||
unserialize('{codeCoverageFilter}')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$result->beStrictAboutTestsThatDoNotTestAnything({isStrictAboutTestsThatDoNotTestAnything});
|
||||
$result->beStrictAboutOutputDuringTests({isStrictAboutOutputDuringTests});
|
||||
$result->enforceTimeLimit({enforcesTimeLimit});
|
||||
$result->beStrictAboutTodoAnnotatedTests({isStrictAboutTodoAnnotatedTests});
|
||||
$result->beStrictAboutResourceUsageDuringSmallTests({isStrictAboutResourceUsageDuringSmallTests});
|
||||
|
||||
$test = new {className}('{name}', unserialize('{data}'), '{dataName}');
|
||||
$test->setDependencyInput(unserialize('{dependencyInput}'));
|
||||
$test->setInIsolation(TRUE);
|
||||
|
||||
ob_end_clean();
|
||||
$test->run($result);
|
||||
$output = '';
|
||||
if (!$test->hasExpectationOnOutput()) {
|
||||
$output = $test->getActualOutput();
|
||||
}
|
||||
|
||||
@rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
|
||||
if ($stdout = stream_get_contents(STDOUT)) {
|
||||
$output = $stdout . $output;
|
||||
$streamMetaData = stream_get_meta_data(STDOUT);
|
||||
if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) {
|
||||
@ftruncate(STDOUT, 0);
|
||||
@rewind(STDOUT);
|
||||
}
|
||||
}
|
||||
|
||||
print serialize(
|
||||
array(
|
||||
'testResult' => $test->getResult(),
|
||||
'numAssertions' => $test->getNumAssertions(),
|
||||
'result' => $result,
|
||||
'output' => $output
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$configurationFilePath = '{configurationFilePath}';
|
||||
|
||||
if ('' !== $configurationFilePath) {
|
||||
$configuration = PHPUnit\Util\Configuration::getInstance($configurationFilePath);
|
||||
$configuration->handlePHPConfiguration();
|
||||
unset($configuration);
|
||||
}
|
||||
|
||||
function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
set_error_handler('__phpunit_error_handler');
|
||||
|
||||
{constants}
|
||||
{included_files}
|
||||
{globals}
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
|
||||
require_once $GLOBALS['__PHPUNIT_BOOTSTRAP'];
|
||||
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
|
||||
}
|
||||
|
||||
__phpunit_run_isolated_test();
|
||||
109
vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist
vendored
Normal file
109
vendor/phpunit/phpunit/src/Util/PHP/Template/TestCaseMethod.tpl.dist
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
||||
|
||||
if (!defined('STDOUT')) {
|
||||
// php://stdout does not obey output buffering. Any output would break
|
||||
// unserialization of child process results in the parent process.
|
||||
define('STDOUT', fopen('php://temp', 'w+b'));
|
||||
define('STDERR', fopen('php://stderr', 'wb'));
|
||||
}
|
||||
|
||||
{iniSettings}
|
||||
ini_set('display_errors', 'stderr');
|
||||
set_include_path('{include_path}');
|
||||
|
||||
$composerAutoload = {composerAutoload};
|
||||
$phar = {phar};
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($composerAutoload) {
|
||||
require_once $composerAutoload;
|
||||
define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload);
|
||||
} else if ($phar) {
|
||||
require $phar;
|
||||
}
|
||||
|
||||
function __phpunit_run_isolated_test()
|
||||
{
|
||||
if (!class_exists('{className}')) {
|
||||
require_once '{filename}';
|
||||
}
|
||||
|
||||
$result = new PHPUnit\Framework\TestResult;
|
||||
|
||||
if ({collectCodeCoverageInformation}) {
|
||||
$result->setCodeCoverage(
|
||||
new CodeCoverage(
|
||||
null,
|
||||
unserialize('{codeCoverageFilter}')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$result->beStrictAboutTestsThatDoNotTestAnything({isStrictAboutTestsThatDoNotTestAnything});
|
||||
$result->beStrictAboutOutputDuringTests({isStrictAboutOutputDuringTests});
|
||||
$result->enforceTimeLimit({enforcesTimeLimit});
|
||||
$result->beStrictAboutTodoAnnotatedTests({isStrictAboutTodoAnnotatedTests});
|
||||
$result->beStrictAboutResourceUsageDuringSmallTests({isStrictAboutResourceUsageDuringSmallTests});
|
||||
|
||||
/** @var TestCase $test */
|
||||
$test = new {className}('{methodName}', unserialize('{data}'), '{dataName}');
|
||||
$test->setDependencyInput(unserialize('{dependencyInput}'));
|
||||
$test->setInIsolation(TRUE);
|
||||
|
||||
ob_end_clean();
|
||||
$test->run($result);
|
||||
$output = '';
|
||||
if (!$test->hasExpectationOnOutput()) {
|
||||
$output = $test->getActualOutput();
|
||||
}
|
||||
|
||||
@rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
|
||||
if ($stdout = stream_get_contents(STDOUT)) {
|
||||
$output = $stdout . $output;
|
||||
$streamMetaData = stream_get_meta_data(STDOUT);
|
||||
if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) {
|
||||
@ftruncate(STDOUT, 0);
|
||||
@rewind(STDOUT);
|
||||
}
|
||||
}
|
||||
|
||||
print serialize(
|
||||
array(
|
||||
'testResult' => $test->getResult(),
|
||||
'numAssertions' => $test->getNumAssertions(),
|
||||
'result' => $result,
|
||||
'output' => $output
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$configurationFilePath = '{configurationFilePath}';
|
||||
|
||||
if ('' !== $configurationFilePath) {
|
||||
$configuration = PHPUnit\Util\Configuration::getInstance($configurationFilePath);
|
||||
$configuration->handlePHPConfiguration();
|
||||
unset($configuration);
|
||||
}
|
||||
|
||||
function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
set_error_handler('__phpunit_error_handler');
|
||||
|
||||
{constants}
|
||||
{included_files}
|
||||
{globals}
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
|
||||
require_once $GLOBALS['__PHPUNIT_BOOTSTRAP'];
|
||||
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
|
||||
}
|
||||
|
||||
__phpunit_run_isolated_test();
|
||||
43
vendor/phpunit/phpunit/src/Util/PHP/WindowsPhpProcess.php
vendored
Normal file
43
vendor/phpunit/phpunit/src/Util/PHP/WindowsPhpProcess.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\PHP;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Windows utility for PHP sub-processes.
|
||||
*
|
||||
* Reading from STDOUT or STDERR hangs forever on Windows if the output is
|
||||
* too large.
|
||||
*
|
||||
* @see https://bugs.php.net/bug.php?id=51800
|
||||
*/
|
||||
class WindowsPhpProcess extends DefaultPhpProcess
|
||||
{
|
||||
protected $useTempFile = true;
|
||||
|
||||
protected function getHandles()
|
||||
{
|
||||
if (false === $stdout_handle = \tmpfile()) {
|
||||
throw new Exception(
|
||||
'A temporary file could not be created; verify that your TEMP environment variable is writable'
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
1 => $stdout_handle
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommand(array $settings, $file = null)
|
||||
{
|
||||
return '"' . parent::getCommand($settings, $file) . '"';
|
||||
}
|
||||
}
|
||||
10
vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
vendored
Normal file
10
vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
eval('?>' . \file_get_contents('php://stdin'));
|
||||
151
vendor/phpunit/phpunit/src/Util/Printer.php
vendored
Normal file
151
vendor/phpunit/phpunit/src/Util/Printer.php
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\Exception;
|
||||
|
||||
/**
|
||||
* Utility class that can print to STDOUT or write to a file.
|
||||
*/
|
||||
class Printer
|
||||
{
|
||||
/**
|
||||
* If true, flush output after every write.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoFlush = false;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
protected $out;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $outTarget;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed $out
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($out = null)
|
||||
{
|
||||
if ($out !== null) {
|
||||
if (\is_string($out)) {
|
||||
if (\strpos($out, 'socket://') === 0) {
|
||||
$out = \explode(':', \str_replace('socket://', '', $out));
|
||||
|
||||
if (\count($out) != 2) {
|
||||
throw new Exception;
|
||||
}
|
||||
|
||||
$this->out = \fsockopen($out[0], $out[1]);
|
||||
} else {
|
||||
if (\strpos($out, 'php://') === false && !\is_dir(\dirname($out))) {
|
||||
$this->createDirectory(\dirname($out));
|
||||
}
|
||||
|
||||
$this->out = \fopen($out, 'wt');
|
||||
}
|
||||
|
||||
$this->outTarget = $out;
|
||||
} else {
|
||||
$this->out = $out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer and close output if it's not to a PHP stream
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if ($this->out && \strncmp($this->outTarget, 'php://', 6) !== 0) {
|
||||
\fclose($this->out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a safe, incremental flush.
|
||||
*
|
||||
* Do not confuse this function with the flush() function of this class,
|
||||
* since the flush() function may close the file being written to, rendering
|
||||
* the current object no longer usable.
|
||||
*/
|
||||
public function incrementalFlush()
|
||||
{
|
||||
if ($this->out) {
|
||||
\fflush($this->out);
|
||||
} else {
|
||||
\flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $buffer
|
||||
*/
|
||||
public function write($buffer)
|
||||
{
|
||||
if ($this->out) {
|
||||
\fwrite($this->out, $buffer);
|
||||
|
||||
if ($this->autoFlush) {
|
||||
$this->incrementalFlush();
|
||||
}
|
||||
} else {
|
||||
if (PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg') {
|
||||
$buffer = \htmlspecialchars($buffer, ENT_SUBSTITUTE);
|
||||
}
|
||||
|
||||
print $buffer;
|
||||
|
||||
if ($this->autoFlush) {
|
||||
$this->incrementalFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check auto-flush mode.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getAutoFlush()
|
||||
{
|
||||
return $this->autoFlush;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set auto-flushing mode.
|
||||
*
|
||||
* If set, *incremental* flushes will be done after each write. This should
|
||||
* not be confused with the different effects of this class' flush() method.
|
||||
*
|
||||
* @param bool $autoFlush
|
||||
*/
|
||||
public function setAutoFlush($autoFlush)
|
||||
{
|
||||
if (\is_bool($autoFlush)) {
|
||||
$this->autoFlush = $autoFlush;
|
||||
} else {
|
||||
throw InvalidArgumentHelper::factory(1, 'boolean');
|
||||
}
|
||||
}
|
||||
|
||||
private function createDirectory(string $directory): bool
|
||||
{
|
||||
return !(!\is_dir($directory) && !@\mkdir($directory, 0777, true) && !\is_dir($directory));
|
||||
}
|
||||
}
|
||||
34
vendor/phpunit/phpunit/src/Util/RegularExpression.php
vendored
Normal file
34
vendor/phpunit/phpunit/src/Util/RegularExpression.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
/**
|
||||
* Error handler that converts PHP errors and warnings to exceptions.
|
||||
*/
|
||||
class RegularExpression
|
||||
{
|
||||
/**
|
||||
* @param string $pattern
|
||||
* @param string $subject
|
||||
* @param null $matches
|
||||
* @param int $flags
|
||||
* @param int $offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function safeMatch($pattern, $subject, $matches = null, $flags = 0, $offset = 0)
|
||||
{
|
||||
$handler_terminator = ErrorHandler::handleErrorOnce(E_WARNING);
|
||||
$match = \preg_match($pattern, $subject, $matches, $flags, $offset);
|
||||
$handler_terminator(); // cleaning
|
||||
|
||||
return $match;
|
||||
}
|
||||
}
|
||||
1193
vendor/phpunit/phpunit/src/Util/Test.php
vendored
Normal file
1193
vendor/phpunit/phpunit/src/Util/Test.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
138
vendor/phpunit/phpunit/src/Util/TestDox/HtmlResultPrinter.php
vendored
Normal file
138
vendor/phpunit/phpunit/src/Util/TestDox/HtmlResultPrinter.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\TestDox;
|
||||
|
||||
/**
|
||||
* Prints TestDox documentation in HTML format.
|
||||
*/
|
||||
class HtmlResultPrinter extends ResultPrinter
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pageHeader = <<<EOT
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Test Documentation</title>
|
||||
<style>
|
||||
body {
|
||||
text-rendering: optimizeLegibility;
|
||||
font-variant-ligatures: common-ligatures;
|
||||
font-kerning: normal;
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
body > ul > li {
|
||||
font-family: Source Serif Pro, PT Sans, Trebuchet MS, Helvetica, Arial;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: Tahoma, Helvetica, Arial;
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
EOT;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $classHeader = <<<EOT
|
||||
|
||||
<h2 id="%s">%s</h2>
|
||||
<ul>
|
||||
|
||||
EOT;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $classFooter = <<<EOT
|
||||
</ul>
|
||||
EOT;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pageFooter = <<<EOT
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT;
|
||||
|
||||
/**
|
||||
* Handler for 'start run' event.
|
||||
*/
|
||||
protected function startRun()
|
||||
{
|
||||
$this->write($this->pageHeader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'start class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function startClass($name)
|
||||
{
|
||||
$this->write(
|
||||
\sprintf(
|
||||
$this->classHeader,
|
||||
$name,
|
||||
$this->currentTestClassPrettified
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'on test' event.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $success
|
||||
*/
|
||||
protected function onTest($name, $success = true)
|
||||
{
|
||||
$this->write(
|
||||
\sprintf(
|
||||
" <li style=\"color: %s;\">%s %s</li>\n",
|
||||
$success ? '#555753' : '#ef2929',
|
||||
$success ? '✓' : '❌',
|
||||
$name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'end class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function endClass($name)
|
||||
{
|
||||
$this->write($this->classFooter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'end run' event.
|
||||
*/
|
||||
protected function endRun()
|
||||
{
|
||||
$this->write($this->pageFooter);
|
||||
}
|
||||
}
|
||||
142
vendor/phpunit/phpunit/src/Util/TestDox/NamePrettifier.php
vendored
Normal file
142
vendor/phpunit/phpunit/src/Util/TestDox/NamePrettifier.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util\TestDox;
|
||||
|
||||
/**
|
||||
* Prettifies class and method names for use in TestDox documentation.
|
||||
*/
|
||||
class NamePrettifier
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = 'Test';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $suffix = 'Test';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $strings = [];
|
||||
|
||||
/**
|
||||
* Prettifies the name of a test class.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function prettifyTestClass($name)
|
||||
{
|
||||
$title = $name;
|
||||
|
||||
if ($this->suffix !== null &&
|
||||
$this->suffix == \substr($name, -1 * \strlen($this->suffix))) {
|
||||
$title = \substr($title, 0, \strripos($title, $this->suffix));
|
||||
}
|
||||
|
||||
if ($this->prefix !== null &&
|
||||
$this->prefix == \substr($name, 0, \strlen($this->prefix))) {
|
||||
$title = \substr($title, \strlen($this->prefix));
|
||||
}
|
||||
|
||||
if (\substr($title, 0, 1) == '\\') {
|
||||
$title = \substr($title, 1);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prettifies the name of a test method.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function prettifyTestMethod($name)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
if (!\is_string($name) || \strlen($name) == 0) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$string = \preg_replace('#\d+$#', '', $name, -1, $count);
|
||||
|
||||
if (\in_array($string, $this->strings)) {
|
||||
$name = $string;
|
||||
} elseif ($count == 0) {
|
||||
$this->strings[] = $string;
|
||||
}
|
||||
|
||||
if (\substr($name, 0, 4) == 'test') {
|
||||
$name = \substr($name, 4);
|
||||
}
|
||||
|
||||
if (\strlen($name) == 0) {
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$name[0] = \strtoupper($name[0]);
|
||||
|
||||
if (\strpos($name, '_') !== false) {
|
||||
return \trim(\str_replace('_', ' ', $name));
|
||||
}
|
||||
|
||||
$max = \strlen($name);
|
||||
$wasNumeric = false;
|
||||
|
||||
for ($i = 0; $i < $max; $i++) {
|
||||
if ($i > 0 && \ord($name[$i]) >= 65 && \ord($name[$i]) <= 90) {
|
||||
$buffer .= ' ' . \strtolower($name[$i]);
|
||||
} else {
|
||||
$isNumeric = \is_numeric($name[$i]);
|
||||
|
||||
if (!$wasNumeric && $isNumeric) {
|
||||
$buffer .= ' ';
|
||||
$wasNumeric = true;
|
||||
}
|
||||
|
||||
if ($wasNumeric && !$isNumeric) {
|
||||
$wasNumeric = false;
|
||||
}
|
||||
|
||||
$buffer .= $name[$i];
|
||||
}
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix of test names.
|
||||
*
|
||||
* @param string $prefix
|
||||
*/
|
||||
public function setPrefix($prefix)
|
||||
{
|
||||
$this->prefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the suffix of test names.
|
||||
*
|
||||
* @param string $suffix
|
||||
*/
|
||||
public function setSuffix($suffix)
|
||||
{
|
||||
$this->suffix = $suffix;
|
||||
}
|
||||
}
|
||||
412
vendor/phpunit/phpunit/src/Util/TestDox/ResultPrinter.php
vendored
Normal file
412
vendor/phpunit/phpunit/src/Util/TestDox/ResultPrinter.php
vendored
Normal file
@@ -0,0 +1,412 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\TestDox;
|
||||
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestListener;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\Framework\WarningTestCase;
|
||||
use PHPUnit\Runner\BaseTestRunner;
|
||||
use PHPUnit\Util\Printer;
|
||||
|
||||
/**
|
||||
* Base class for printers of TestDox documentation.
|
||||
*/
|
||||
abstract class ResultPrinter extends Printer implements TestListener
|
||||
{
|
||||
/**
|
||||
* @var NamePrettifier
|
||||
*/
|
||||
protected $prettifier;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $testClass = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $testStatus;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $tests = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $successful = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $warned = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $failed = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $risky = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $skipped = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $incomplete = 0;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $currentTestClassPrettified;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $currentTestMethodPrettified;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $groups;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $excludeGroups;
|
||||
|
||||
/**
|
||||
* @param resource $out
|
||||
* @param array $groups
|
||||
* @param array $excludeGroups
|
||||
*/
|
||||
public function __construct($out = null, array $groups = [], array $excludeGroups = [])
|
||||
{
|
||||
parent::__construct($out);
|
||||
|
||||
$this->groups = $groups;
|
||||
$this->excludeGroups = $excludeGroups;
|
||||
|
||||
$this->prettifier = new NamePrettifier;
|
||||
$this->startRun();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer and close output.
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->doEndClass();
|
||||
$this->endRun();
|
||||
|
||||
parent::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* An error occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addError(Test $test, \Exception $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_ERROR;
|
||||
$this->failed++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param Warning $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addWarning(Test $test, Warning $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_WARNING;
|
||||
$this->warned++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A failure occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param AssertionFailedError $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addFailure(Test $test, AssertionFailedError $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_FAILURE;
|
||||
$this->failed++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Incomplete test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addIncompleteTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_INCOMPLETE;
|
||||
$this->incomplete++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Risky test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addRiskyTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_RISKY;
|
||||
$this->risky++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skipped test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addSkippedTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_SKIPPED;
|
||||
$this->skipped++;
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite started.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function startTestSuite(TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A testsuite ended.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function endTestSuite(TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A test started.
|
||||
*
|
||||
* @param Test $test
|
||||
*/
|
||||
public function startTest(Test $test)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$class = \get_class($test);
|
||||
|
||||
if ($this->testClass != $class) {
|
||||
if ($this->testClass != '') {
|
||||
$this->doEndClass();
|
||||
}
|
||||
|
||||
$classAnnotations = \PHPUnit\Util\Test::parseTestMethodAnnotations($class);
|
||||
if (isset($classAnnotations['class']['testdox'][0])) {
|
||||
$this->currentTestClassPrettified = $classAnnotations['class']['testdox'][0];
|
||||
} else {
|
||||
$this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class);
|
||||
}
|
||||
|
||||
$this->startClass($class);
|
||||
|
||||
$this->testClass = $class;
|
||||
$this->tests = [];
|
||||
}
|
||||
|
||||
if ($test instanceof TestCase) {
|
||||
$annotations = $test->getAnnotations();
|
||||
|
||||
if (isset($annotations['method']['testdox'][0])) {
|
||||
$this->currentTestMethodPrettified = $annotations['method']['testdox'][0];
|
||||
} else {
|
||||
$this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(false));
|
||||
}
|
||||
|
||||
if ($test->usesDataProvider()) {
|
||||
$this->currentTestMethodPrettified .= ' ' . $test->dataDescription();
|
||||
}
|
||||
}
|
||||
|
||||
$this->testStatus = BaseTestRunner::STATUS_PASSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* A test ended.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param float $time
|
||||
*/
|
||||
public function endTest(Test $test, $time)
|
||||
{
|
||||
if (!$this->isOfInterest($test)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($this->tests[$this->currentTestMethodPrettified])) {
|
||||
if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
|
||||
$this->tests[$this->currentTestMethodPrettified]['success'] = 1;
|
||||
$this->tests[$this->currentTestMethodPrettified]['failure'] = 0;
|
||||
} else {
|
||||
$this->tests[$this->currentTestMethodPrettified]['success'] = 0;
|
||||
$this->tests[$this->currentTestMethodPrettified]['failure'] = 1;
|
||||
}
|
||||
} else {
|
||||
if ($this->testStatus == BaseTestRunner::STATUS_PASSED) {
|
||||
$this->tests[$this->currentTestMethodPrettified]['success']++;
|
||||
} else {
|
||||
$this->tests[$this->currentTestMethodPrettified]['failure']++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->currentTestClassPrettified = null;
|
||||
$this->currentTestMethodPrettified = null;
|
||||
}
|
||||
|
||||
protected function doEndClass()
|
||||
{
|
||||
foreach ($this->tests as $name => $data) {
|
||||
$this->onTest($name, $data['failure'] == 0);
|
||||
}
|
||||
|
||||
$this->endClass($this->testClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'start run' event.
|
||||
*/
|
||||
protected function startRun()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'start class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function startClass($name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'on test' event.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $success
|
||||
*/
|
||||
protected function onTest($name, $success = true)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'end class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function endClass($name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'end run' event.
|
||||
*/
|
||||
protected function endRun()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Test $test
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isOfInterest(Test $test)
|
||||
{
|
||||
if (!$test instanceof TestCase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($test instanceof WarningTestCase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->groups)) {
|
||||
foreach ($test->getGroups() as $group) {
|
||||
if (\in_array($group, $this->groups)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->excludeGroups)) {
|
||||
foreach ($test->getGroups() as $group) {
|
||||
if (\in_array($group, $this->excludeGroups)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
53
vendor/phpunit/phpunit/src/Util/TestDox/TextResultPrinter.php
vendored
Normal file
53
vendor/phpunit/phpunit/src/Util/TestDox/TextResultPrinter.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\TestDox;
|
||||
|
||||
/**
|
||||
* Prints TestDox documentation in text format.
|
||||
*/
|
||||
class TextResultPrinter extends ResultPrinter
|
||||
{
|
||||
/**
|
||||
* Handler for 'start class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function startClass($name)
|
||||
{
|
||||
$this->write($this->currentTestClassPrettified . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'on test' event.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $success
|
||||
*/
|
||||
protected function onTest($name, $success = true)
|
||||
{
|
||||
if ($success) {
|
||||
$this->write(' [x] ');
|
||||
} else {
|
||||
$this->write(' [ ] ');
|
||||
}
|
||||
|
||||
$this->write($name . "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for 'end class' event.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
protected function endClass($name)
|
||||
{
|
||||
$this->write("\n");
|
||||
}
|
||||
}
|
||||
238
vendor/phpunit/phpunit/src/Util/TestDox/XmlResultPrinter.php
vendored
Normal file
238
vendor/phpunit/phpunit/src/Util/TestDox/XmlResultPrinter.php
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util\TestDox;
|
||||
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
use PHPUnit\Framework\Exception;
|
||||
use PHPUnit\Framework\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestListener;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Framework\Warning;
|
||||
use PHPUnit\Util\Printer;
|
||||
use ReflectionClass;
|
||||
|
||||
class XmlResultPrinter extends Printer implements TestListener
|
||||
{
|
||||
/**
|
||||
* @var DOMDocument
|
||||
*/
|
||||
private $document;
|
||||
|
||||
/**
|
||||
* @var DOMElement
|
||||
*/
|
||||
private $root;
|
||||
|
||||
/**
|
||||
* @var NamePrettifier
|
||||
*/
|
||||
private $prettifier;
|
||||
|
||||
/**
|
||||
* @var \Exception|null
|
||||
*/
|
||||
private $exception;
|
||||
|
||||
/**
|
||||
* @param string|resource $out
|
||||
*/
|
||||
public function __construct($out = null)
|
||||
{
|
||||
$this->document = new DOMDocument('1.0', 'UTF-8');
|
||||
$this->document->formatOutput = true;
|
||||
|
||||
$this->root = $this->document->createElement('tests');
|
||||
$this->document->appendChild($this->root);
|
||||
|
||||
$this->prettifier = new NamePrettifier;
|
||||
|
||||
parent::__construct($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush buffer and close output.
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->write($this->document->saveXML());
|
||||
|
||||
parent::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* An error occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addError(Test $test, \Exception $e, $time)
|
||||
{
|
||||
$this->exception = $e;
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param Warning $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addWarning(Test $test, Warning $e, $time)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A failure occurred.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param AssertionFailedError $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addFailure(Test $test, AssertionFailedError $e, $time)
|
||||
{
|
||||
$this->exception = $e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Incomplete test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addIncompleteTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Risky test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addRiskyTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Skipped test.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param \Exception $e
|
||||
* @param float $time
|
||||
*/
|
||||
public function addSkippedTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A test suite started.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function startTestSuite(TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A test suite ended.
|
||||
*
|
||||
* @param TestSuite $suite
|
||||
*/
|
||||
public function endTestSuite(TestSuite $suite)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* A test started.
|
||||
*
|
||||
* @param Test $test
|
||||
*/
|
||||
public function startTest(Test $test)
|
||||
{
|
||||
$this->exception = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A test ended.
|
||||
*
|
||||
* @param Test $test
|
||||
* @param float $time
|
||||
*/
|
||||
public function endTest(Test $test, $time)
|
||||
{
|
||||
if (!$test instanceof TestCase) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* @var TestCase $test */
|
||||
|
||||
$groups = \array_filter(
|
||||
$test->getGroups(),
|
||||
function ($group) {
|
||||
if ($group == 'small' || $group == 'medium' || $group == 'large') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
$node = $this->document->createElement('test');
|
||||
|
||||
$node->setAttribute('className', \get_class($test));
|
||||
$node->setAttribute('methodName', $test->getName());
|
||||
$node->setAttribute('prettifiedClassName', $this->prettifier->prettifyTestClass(\get_class($test)));
|
||||
$node->setAttribute('prettifiedMethodName', $this->prettifier->prettifyTestMethod($test->getName()));
|
||||
$node->setAttribute('status', $test->getStatus());
|
||||
$node->setAttribute('time', $time);
|
||||
$node->setAttribute('size', $test->getSize());
|
||||
$node->setAttribute('groups', \implode(',', $groups));
|
||||
|
||||
$inlineAnnotations = \PHPUnit\Util\Test::getInlineAnnotations(\get_class($test), $test->getName());
|
||||
|
||||
if (isset($inlineAnnotations['given']) && isset($inlineAnnotations['when']) && isset($inlineAnnotations['then'])) {
|
||||
$node->setAttribute('given', $inlineAnnotations['given']['value']);
|
||||
$node->setAttribute('givenStartLine', $inlineAnnotations['given']['line']);
|
||||
$node->setAttribute('when', $inlineAnnotations['when']['value']);
|
||||
$node->setAttribute('whenStartLine', $inlineAnnotations['when']['line']);
|
||||
$node->setAttribute('then', $inlineAnnotations['then']['value']);
|
||||
$node->setAttribute('thenStartLine', $inlineAnnotations['then']['line']);
|
||||
}
|
||||
|
||||
if ($this->exception !== null) {
|
||||
if ($this->exception instanceof Exception) {
|
||||
$steps = $this->exception->getSerializableTrace();
|
||||
} else {
|
||||
$steps = $this->exception->getTrace();
|
||||
}
|
||||
|
||||
$class = new ReflectionClass($test);
|
||||
$file = $class->getFileName();
|
||||
|
||||
foreach ($steps as $step) {
|
||||
if (isset($step['file']) && $step['file'] == $file) {
|
||||
$node->setAttribute('exceptionLine', $step['line']);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$node->setAttribute('exceptionMessage', $this->exception->getMessage());
|
||||
}
|
||||
|
||||
$this->root->appendChild($node);
|
||||
}
|
||||
}
|
||||
44
vendor/phpunit/phpunit/src/Util/TextTestListRenderer.php
vendored
Normal file
44
vendor/phpunit/phpunit/src/Util/TextTestListRenderer.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Runner\PhptTestCase;
|
||||
|
||||
class TextTestListRenderer
|
||||
{
|
||||
public function render(TestSuite $suite): string
|
||||
{
|
||||
$buffer = 'Available test(s):' . PHP_EOL;
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
|
||||
if ($test instanceof TestCase) {
|
||||
$name = \sprintf(
|
||||
'%s::%s',
|
||||
\get_class($test),
|
||||
\str_replace(' with data set ', '', $test->getName())
|
||||
);
|
||||
} elseif ($test instanceof PhptTestCase) {
|
||||
$name = $test->getName();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$buffer .= \sprintf(
|
||||
' - %s' . PHP_EOL,
|
||||
$name
|
||||
);
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
43
vendor/phpunit/phpunit/src/Util/Type.php
vendored
Normal file
43
vendor/phpunit/phpunit/src/Util/Type.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
/**
|
||||
* Utility class for textual type (and value) representation.
|
||||
*/
|
||||
class Type
|
||||
{
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isType($type)
|
||||
{
|
||||
return \in_array(
|
||||
$type,
|
||||
[
|
||||
'numeric',
|
||||
'integer',
|
||||
'int',
|
||||
'float',
|
||||
'string',
|
||||
'boolean',
|
||||
'bool',
|
||||
'null',
|
||||
'array',
|
||||
'object',
|
||||
'resource',
|
||||
'scalar'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
314
vendor/phpunit/phpunit/src/Util/Xml.php
vendored
Normal file
314
vendor/phpunit/phpunit/src/Util/Xml.php
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use DOMCharacterData;
|
||||
use DOMDocument;
|
||||
use DOMElement;
|
||||
use DOMNode;
|
||||
use DOMText;
|
||||
use PHPUnit\Framework\Exception;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* XML helpers.
|
||||
*/
|
||||
class Xml
|
||||
{
|
||||
/**
|
||||
* Load an $actual document into a DOMDocument. This is called
|
||||
* from the selector assertions.
|
||||
*
|
||||
* If $actual is already a DOMDocument, it is returned with
|
||||
* no changes. Otherwise, $actual is loaded into a new DOMDocument
|
||||
* as either HTML or XML, depending on the value of $isHtml. If $isHtml is
|
||||
* false and $xinclude is true, xinclude is performed on the loaded
|
||||
* DOMDocument.
|
||||
*
|
||||
* Note: prior to PHPUnit 3.3.0, this method loaded a file and
|
||||
* not a string as it currently does. To load a file into a
|
||||
* DOMDocument, use loadFile() instead.
|
||||
*
|
||||
* @param string|DOMDocument $actual
|
||||
* @param bool $isHtml
|
||||
* @param string $filename
|
||||
* @param bool $xinclude
|
||||
* @param bool $strict
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public static function load($actual, $isHtml = false, $filename = '', $xinclude = false, $strict = false)
|
||||
{
|
||||
if ($actual instanceof DOMDocument) {
|
||||
return $actual;
|
||||
}
|
||||
|
||||
if (!\is_string($actual)) {
|
||||
throw new Exception('Could not load XML from ' . \gettype($actual));
|
||||
}
|
||||
|
||||
if ($actual === '') {
|
||||
throw new Exception('Could not load XML from empty string');
|
||||
}
|
||||
|
||||
// Required for XInclude on Windows.
|
||||
if ($xinclude) {
|
||||
$cwd = \getcwd();
|
||||
@\chdir(\dirname($filename));
|
||||
}
|
||||
|
||||
$document = new DOMDocument;
|
||||
$document->preserveWhiteSpace = false;
|
||||
|
||||
$internal = \libxml_use_internal_errors(true);
|
||||
$message = '';
|
||||
$reporting = \error_reporting(0);
|
||||
|
||||
if ('' !== $filename) {
|
||||
// Necessary for xinclude
|
||||
$document->documentURI = $filename;
|
||||
}
|
||||
|
||||
if ($isHtml) {
|
||||
$loaded = $document->loadHTML($actual);
|
||||
} else {
|
||||
$loaded = $document->loadXML($actual);
|
||||
}
|
||||
|
||||
if (!$isHtml && $xinclude) {
|
||||
$document->xinclude();
|
||||
}
|
||||
|
||||
foreach (\libxml_get_errors() as $error) {
|
||||
$message .= "\n" . $error->message;
|
||||
}
|
||||
|
||||
\libxml_use_internal_errors($internal);
|
||||
\error_reporting($reporting);
|
||||
|
||||
if (isset($cwd)) {
|
||||
@\chdir($cwd);
|
||||
}
|
||||
|
||||
if ($loaded === false || ($strict && $message !== '')) {
|
||||
if ($filename !== '') {
|
||||
throw new Exception(
|
||||
\sprintf(
|
||||
'Could not load "%s".%s',
|
||||
$filename,
|
||||
$message != '' ? "\n" . $message : ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($message === '') {
|
||||
$message = 'Could not load XML for unknown reason';
|
||||
}
|
||||
|
||||
throw new Exception($message);
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an XML (or HTML) file into a DOMDocument object.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param bool $isHtml
|
||||
* @param bool $xinclude
|
||||
* @param bool $strict
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public static function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false)
|
||||
{
|
||||
$reporting = \error_reporting(0);
|
||||
$contents = \file_get_contents($filename);
|
||||
\error_reporting($reporting);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new Exception(
|
||||
\sprintf(
|
||||
'Could not read "%s".',
|
||||
$filename
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return self::load($contents, $isHtml, $filename, $xinclude, $strict);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DOMNode $node
|
||||
*/
|
||||
public static function removeCharacterDataNodes(DOMNode $node)
|
||||
{
|
||||
if ($node->hasChildNodes()) {
|
||||
for ($i = $node->childNodes->length - 1; $i >= 0; $i--) {
|
||||
if (($child = $node->childNodes->item($i)) instanceof DOMCharacterData) {
|
||||
$node->removeChild($child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a string for the use in XML documents
|
||||
* Any Unicode character is allowed, excluding the surrogate blocks, FFFE,
|
||||
* and FFFF (not even as character reference).
|
||||
* See http://www.w3.org/TR/xml/#charsets
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function prepareString($string)
|
||||
{
|
||||
return \preg_replace(
|
||||
'/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
|
||||
'',
|
||||
\htmlspecialchars(
|
||||
self::convertToUtf8($string),
|
||||
ENT_QUOTES,
|
||||
'UTF-8'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Convert" a DOMElement object into a PHP variable.
|
||||
*
|
||||
* @param DOMElement $element
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function xmlToVariable(DOMElement $element)
|
||||
{
|
||||
$variable = null;
|
||||
|
||||
switch ($element->tagName) {
|
||||
case 'array':
|
||||
$variable = [];
|
||||
|
||||
foreach ($element->childNodes as $entry) {
|
||||
if (!$entry instanceof DOMElement || $entry->tagName !== 'element') {
|
||||
continue;
|
||||
}
|
||||
$item = $entry->childNodes->item(0);
|
||||
|
||||
if ($item instanceof DOMText) {
|
||||
$item = $entry->childNodes->item(1);
|
||||
}
|
||||
|
||||
$value = self::xmlToVariable($item);
|
||||
|
||||
if ($entry->hasAttribute('key')) {
|
||||
$variable[(string) $entry->getAttribute('key')] = $value;
|
||||
} else {
|
||||
$variable[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'object':
|
||||
$className = $element->getAttribute('class');
|
||||
|
||||
if ($element->hasChildNodes()) {
|
||||
$arguments = $element->childNodes->item(0)->childNodes;
|
||||
$constructorArgs = [];
|
||||
|
||||
foreach ($arguments as $argument) {
|
||||
if ($argument instanceof DOMElement) {
|
||||
$constructorArgs[] = self::xmlToVariable($argument);
|
||||
}
|
||||
}
|
||||
|
||||
$class = new ReflectionClass($className);
|
||||
$variable = $class->newInstanceArgs($constructorArgs);
|
||||
} else {
|
||||
$variable = new $className;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
$variable = $element->textContent == 'true';
|
||||
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
case 'double':
|
||||
case 'string':
|
||||
$variable = $element->textContent;
|
||||
|
||||
\settype($variable, $element->tagName);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return $variable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string to UTF-8 encoding.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function convertToUtf8($string)
|
||||
{
|
||||
if (!self::isUtf8($string)) {
|
||||
if (\function_exists('mb_convert_encoding')) {
|
||||
return \mb_convert_encoding($string, 'UTF-8');
|
||||
}
|
||||
|
||||
return \utf8_encode($string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a string for UTF-8 encoding.
|
||||
*
|
||||
* @param string $string
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function isUtf8($string)
|
||||
{
|
||||
$length = \strlen($string);
|
||||
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
if (\ord($string[$i]) < 0x80) {
|
||||
$n = 0;
|
||||
} elseif ((\ord($string[$i]) & 0xE0) == 0xC0) {
|
||||
$n = 1;
|
||||
} elseif ((\ord($string[$i]) & 0xF0) == 0xE0) {
|
||||
$n = 2;
|
||||
} elseif ((\ord($string[$i]) & 0xF0) == 0xF0) {
|
||||
$n = 3;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $n; $j++) {
|
||||
if ((++$i == $length) || ((\ord($string[$i]) & 0xC0) != 0x80)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
82
vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php
vendored
Normal file
82
vendor/phpunit/phpunit/src/Util/XmlTestListRenderer.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of PHPUnit.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Util;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Runner\PhptTestCase;
|
||||
|
||||
class XmlTestListRenderer
|
||||
{
|
||||
public function render(TestSuite $suite): string
|
||||
{
|
||||
$writer = new \XmlWriter;
|
||||
|
||||
$writer->openMemory();
|
||||
$writer->setIndent(true);
|
||||
$writer->startDocument();
|
||||
$writer->startElement('tests');
|
||||
|
||||
$currentTestCase = null;
|
||||
|
||||
foreach (new \RecursiveIteratorIterator($suite->getIterator()) as $test) {
|
||||
if ($test instanceof TestCase) {
|
||||
if (\get_class($test) !== $currentTestCase) {
|
||||
if ($currentTestCase !== null) {
|
||||
$writer->endElement();
|
||||
}
|
||||
|
||||
$writer->startElement('testCaseClass');
|
||||
$writer->writeAttribute('name', \get_class($test));
|
||||
|
||||
$currentTestCase = \get_class($test);
|
||||
}
|
||||
|
||||
$writer->startElement('testCaseMethod');
|
||||
$writer->writeAttribute('name', $test->getName(false));
|
||||
$writer->writeAttribute('groups', \implode(',', $test->getGroups()));
|
||||
|
||||
if (!empty($test->getDataSetAsString(false))) {
|
||||
$writer->writeAttribute(
|
||||
'dataSet',
|
||||
\str_replace(
|
||||
' with data set ',
|
||||
'',
|
||||
$test->getDataSetAsString(false)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$writer->endElement();
|
||||
} elseif ($test instanceof PhptTestCase) {
|
||||
if ($currentTestCase !== null) {
|
||||
$writer->endElement();
|
||||
|
||||
$currentTestCase = null;
|
||||
}
|
||||
|
||||
$writer->startElement('phptFile');
|
||||
$writer->writeAttribute('path', $test->getName());
|
||||
$writer->endElement();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($currentTestCase !== null) {
|
||||
$writer->endElement();
|
||||
}
|
||||
|
||||
$writer->endElement();
|
||||
|
||||
return $writer->outputMemory();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user