Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch '7.1'
  • Loading branch information
sebastianbergmann committed Apr 6, 2018
2 parents 1d39a52 + 7044c3a commit 64b41ec
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Framework/Constraint/Exception.php
Expand Up @@ -60,6 +60,7 @@ protected function failureDescription($other): string
{
if ($other !== null) {
$message = '';

if ($other instanceof Throwable) {
$message = '. Message was: "' . $other->getMessage() . '" at'
. "\n" . Filter::getFilteredStacktrace($other);
Expand Down
1 change: 1 addition & 0 deletions src/Framework/Constraint/IsJson.php
Expand Up @@ -35,6 +35,7 @@ protected function matches($other): bool
}

\json_decode($other);

if (\json_last_error()) {
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/Framework/TestCase.php
Expand Up @@ -710,6 +710,7 @@ public function run(TestResult $result = null): TestResult
$iniSettings = GlobalState::getIniSettingsAsString();
} else {
$constants = '';

if (!empty($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
$globals = '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . \var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], true) . ";\n";
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/Runner/PhptTestCase.php
Expand Up @@ -166,6 +166,7 @@ public function run(TestResult $result = null): TestResult
$this->assertPhptExpectation($sections, $jobResult['stdout']);
} catch (AssertionFailedError $e) {
$failure = $e;

if ($xfail !== false) {
$failure = new IncompleteTestError($xfail, 0, $e);
}
Expand Down Expand Up @@ -302,6 +303,7 @@ private function runSkip(array &$sections, TestResult $result, array $settings):

if (!\strncasecmp('skip', \ltrim($jobResult['stdout']), 4)) {
$message = '';

if (\preg_match('/^\s*skip\s*(.+)\s*/i', $jobResult['stdout'], $skipMatch)) {
$message = \substr($skipMatch[1], 2);
}
Expand Down Expand Up @@ -359,6 +361,7 @@ private function parse(): array

continue;
}

if (empty($section)) {
throw new Exception('Invalid PHPT file');
}
Expand Down Expand Up @@ -496,16 +499,19 @@ private function renderForCoverage(array &$settings): void
);

$composerAutoload = '\'\'';

if (\defined('PHPUNIT_COMPOSER_INSTALL') && !\defined('PHPUNIT_TESTSUITE')) {
$composerAutoload = \var_export(PHPUNIT_COMPOSER_INSTALL, true);
}

$phar = '\'\'';

if (\defined('__PHPUNIT_PHAR__')) {
$phar = \var_export(__PHPUNIT_PHAR__, true);
}

$globals = '';

if (!empty($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
$globals = '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = ' . \var_export($GLOBALS['__PHPUNIT_BOOTSTRAP'], true) . ";\n";
}
Expand Down
1 change: 1 addition & 0 deletions src/Runner/StandardTestSuiteLoader.php
Expand Up @@ -48,6 +48,7 @@ public function load(string $suiteClassName, string $suiteClassFile = ''): Refle

foreach ($loadedClasses as $loadedClass) {
$class = new ReflectionClass($loadedClass);

if (\substr($loadedClass, $offset) === $suiteClassName &&
$class->getFileName() == $filename) {
$suiteClassName = $loadedClass;
Expand Down
1 change: 1 addition & 0 deletions src/TextUI/Command.php
Expand Up @@ -694,6 +694,7 @@ protected function handleArguments(array $argv): void
$optionName = \str_replace('--', '', $option[0]);

$handler = null;

if (isset($this->longOptions[$optionName])) {
$handler = $this->longOptions[$optionName];
} elseif (isset($this->longOptions[$optionName . '='])) {
Expand Down
2 changes: 2 additions & 0 deletions src/Util/Configuration.php
Expand Up @@ -427,6 +427,7 @@ public function getLoggingConfiguration(): array
false
);
}

if ($log->hasAttribute('showOnlySummary')) {
$result['coverageTextShowOnlySummary'] = $this->getBoolean(
(string) $log->getAttribute('showOnlySummary'),
Expand Down Expand Up @@ -959,6 +960,7 @@ private function getTestSuite(DOMElement $testSuiteNode, string $testSuiteFilter

foreach ($testSuiteNode->getElementsByTagName('exclude') as $excludeNode) {
$excludeFile = (string) $excludeNode->textContent;

if ($excludeFile) {
$exclude[] = $this->toAbsolutePath($excludeFile);
}
Expand Down
1 change: 1 addition & 0 deletions src/Util/Getopt.php
Expand Up @@ -60,6 +60,7 @@ public static function getopt(array $args, string $short_options, array $long_op

continue;
}

if (\strlen($arg) > 1 && $arg[1] === '-') {
self::parseLongOption(
\substr($arg, 2),
Expand Down
2 changes: 2 additions & 0 deletions src/Util/Log/JUnit.php
Expand Up @@ -377,6 +377,8 @@ public function setWriteDocument($flag): ?string
/**
* Method which generalizes addError() and addFailure()
*
* @param mixed $type
*
* @throws \InvalidArgumentException
*/
private function doAddFault(Test $test, \Throwable $t, float $time, $type): void
Expand Down
1 change: 1 addition & 0 deletions src/Util/PHP/AbstractPhpProcess.php
Expand Up @@ -342,6 +342,7 @@ private function getException(TestFailure $error): Exception

if ($exception instanceof __PHP_Incomplete_Class) {
$exceptionArray = [];

foreach ((array) $exception as $key => $value) {
$key = \substr($key, \strrpos($key, "\0") + 1);
$exceptionArray[$key] = $value;
Expand Down
2 changes: 2 additions & 0 deletions src/Util/PHP/DefaultPhpProcess.php
Expand Up @@ -114,6 +114,7 @@ protected function runProcess(string $job, array $settings): array
if ($n === false) {
break;
}

if ($n === 0) {
\proc_terminate($process, 9);

Expand All @@ -124,6 +125,7 @@ protected function runProcess(string $job, array $settings): array
)
);
}

if ($n > 0) {
foreach ($r as $pipe) {
$pipeOffset = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/Util/Printer.php
Expand Up @@ -36,6 +36,8 @@ class Printer
/**
* Constructor.
*
* @param null|mixed $out
*
* @throws Exception
*/
public function __construct($out = null)
Expand Down
1 change: 1 addition & 0 deletions src/Util/Test.php
Expand Up @@ -282,6 +282,7 @@ public static function getMissingRequirements(string $className, string $methodN

if (!empty($required['OS'])) {
$requiredOsPattern = \sprintf('/%s/i', \addcslashes($required['OS'], '/'));

if (!\preg_match($requiredOsPattern, PHP_OS)) {
$missing[] = \sprintf('Operating system matching %s is required.', $requiredOsPattern);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Util/TestDox/HtmlResultPrinter.php
Expand Up @@ -100,6 +100,8 @@ protected function startClass(string $name): void

/**
* Handler for 'on test' event.
*
* @param mixed $name
*/
protected function onTest($name, bool $success = true): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Util/TestDox/ResultPrinter.php
Expand Up @@ -304,6 +304,8 @@ protected function startClass(string $name): void

/**
* Handler for 'on test' event.
*
* @param mixed $name
*/
protected function onTest($name, bool $success = true): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/Util/TestDox/TextResultPrinter.php
Expand Up @@ -25,6 +25,8 @@ protected function startClass(string $name): void

/**
* Handler for 'on test' event.
*
* @param mixed $name
*/
protected function onTest($name, bool $success = true): void
{
Expand Down
1 change: 1 addition & 0 deletions tests/Util/JsonTest.php
Expand Up @@ -28,6 +28,7 @@ public function testCanonicalize($actual, $expected, $expectError): void
{
[$error, $canonicalized] = Json::canonicalize($actual);
$this->assertEquals($expectError, $error);

if (!$expectError) {
$this->assertEquals($expected, $canonicalized);
}
Expand Down
1 change: 1 addition & 0 deletions tests/Util/TestTest.php
Expand Up @@ -337,6 +337,7 @@ public function requirementsProvider()
public function testGetRequirementsWithVersionConstraints($test, array $result): void
{
$requirements = Test::getRequirements(\RequirementsTest::class, $test);

foreach ($result as $type => $expected_requirement) {
$this->assertArrayHasKey(
"{$type}_constraint",
Expand Down

0 comments on commit 64b41ec

Please sign in to comment.