Inital commit for unit test configuration
This commit is contained in:

committed by
Manish Verma

parent
2f0796e954
commit
e0436b7757
11
vendor/phpunit/phpunit/ChangeLog-6.5.md
vendored
11
vendor/phpunit/phpunit/ChangeLog-6.5.md
vendored
@@ -2,6 +2,15 @@
|
||||
|
||||
All notable changes of the PHPUnit 6.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [6.5.12] - 2018-08-22
|
||||
|
||||
* Fixed [#3248](https://github.com/sebastianbergmann/phpunit/issues/3248) and [#3233](https://github.com/sebastianbergmann/phpunit/issues/3233): `phpunit.xsd` dictates element order where it should not
|
||||
* Fixed [#3251](https://github.com/sebastianbergmann/phpunit/issues/3251): TeamCity result logger is missing test duration information
|
||||
|
||||
## [6.5.11] - 2018-08-07
|
||||
|
||||
* Fixed [#3219](https://github.com/sebastianbergmann/phpunit/issues/3219): `getMockFromWsdl()` generates invalid PHP code when WSDL filename contains special characters
|
||||
|
||||
## [6.5.10] - 2018-08-03
|
||||
|
||||
### Fixed
|
||||
@@ -76,6 +85,8 @@ All notable changes of the PHPUnit 6.5 release series are documented in this fil
|
||||
* Fixed [#2654](https://github.com/sebastianbergmann/phpunit/issues/2654): Problems with `assertJsonStringEqualsJsonString()`
|
||||
* Fixed [#2810](https://github.com/sebastianbergmann/phpunit/pull/2810): Code Coverage for PHPT tests does not work
|
||||
|
||||
[6.5.12]: https://github.com/sebastianbergmann/phpunit/compare/6.5.11...6.5.12
|
||||
[6.5.11]: https://github.com/sebastianbergmann/phpunit/compare/6.5.10...6.5.11
|
||||
[6.5.10]: https://github.com/sebastianbergmann/phpunit/compare/6.5.9...6.5.10
|
||||
[6.5.9]: https://github.com/sebastianbergmann/phpunit/compare/6.5.8...6.5.9
|
||||
[6.5.8]: https://github.com/sebastianbergmann/phpunit/compare/6.5.7...6.5.8
|
||||
|
17
vendor/phpunit/phpunit/ChangeLog-7.3.md
vendored
17
vendor/phpunit/phpunit/ChangeLog-7.3.md
vendored
@@ -2,6 +2,21 @@
|
||||
|
||||
All notable changes of the PHPUnit 7.3 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
|
||||
|
||||
## [7.3.3] - 2018-09-01
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3265](https://github.com/sebastianbergmann/phpunit/pull/3265): Slashes are unnecessarily escaped in prettified JSON
|
||||
* Fixed [#3267](https://github.com/sebastianbergmann/phpunit/pull/3267): `%` not escaped correctly for `StringMatchesFormat` constraint
|
||||
|
||||
## [7.3.2] - 2018-08-22
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed [#3219](https://github.com/sebastianbergmann/phpunit/issues/3219): `getMockFromWsdl()` generates invalid PHP code when WSDL filename contains special characters
|
||||
* Fixed [#3248](https://github.com/sebastianbergmann/phpunit/issues/3248) and [#3233](https://github.com/sebastianbergmann/phpunit/issues/3233): `phpunit.xsd` dictates element order where it should not
|
||||
* Fixed [#3251](https://github.com/sebastianbergmann/phpunit/issues/3251): TeamCity result logger is missing test duration information
|
||||
|
||||
## [7.3.1] - 2018-08-07
|
||||
|
||||
### Changed
|
||||
@@ -37,6 +52,8 @@ All notable changes of the PHPUnit 7.3 release series are documented in this fil
|
||||
* Fixed [#3222](https://github.com/sebastianbergmann/phpunit/pull/3222): Priority of `@covers` and `@coversNothing` is wrong
|
||||
* Fixed [#3225](https://github.com/sebastianbergmann/phpunit/issues/3225): `coverage-php` missing from `phpunit.xsd`
|
||||
|
||||
[7.3.3]: https://github.com/sebastianbergmann/phpunit/compare/7.3.2...7.3.3
|
||||
[7.3.2]: https://github.com/sebastianbergmann/phpunit/compare/7.3.1...7.3.2
|
||||
[7.3.1]: https://github.com/sebastianbergmann/phpunit/compare/7.3.0...7.3.1
|
||||
[7.3.0]: https://github.com/sebastianbergmann/phpunit/compare/7.2...7.3.0
|
||||
|
||||
|
2
vendor/phpunit/phpunit/phive.xml
vendored
2
vendor/phpunit/phpunit/phive.xml
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phive xmlns="https://phar.io/phive">
|
||||
<phar name="phpab" version="^1.24.1" installed="1.25.0" location="./build/tools/phpab" copy="true"/>
|
||||
<phar name="php-cs-fixer" version="^2.12.0" installed="2.12.2" location="./build/tools/php-cs-fixer" copy="true"/>
|
||||
<phar name="php-cs-fixer" version="^2.12.0" installed="2.13.0" location="./build/tools/php-cs-fixer" copy="true"/>
|
||||
<phar name="phpdox" version="^0.11.2" installed="0.11.2" location="./build/tools/phpdox" copy="true"/>
|
||||
<phar name="phploc" version="^4.0.1" installed="4.0.1" location="./build/tools/phploc" copy="true"/>
|
||||
<phar name="phpstan" version="^0.10.1" installed="0.10.1" location="./build/tools/phpstan" copy="true"/>
|
||||
|
40
vendor/phpunit/phpunit/phpunit.xsd
vendored
40
vendor/phpunit/phpunit/phpunit.xsd
vendored
@@ -18,12 +18,14 @@
|
||||
</xs:complexType>
|
||||
<xs:complexType name="filterType">
|
||||
<xs:sequence>
|
||||
<xs:group ref="pathGroup"/>
|
||||
<xs:element name="exclude" maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:group ref="pathGroup"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:choice maxOccurs="unbounded" minOccurs="0">
|
||||
<xs:group ref="pathGroup"/>
|
||||
<xs:element name="exclude">
|
||||
<xs:complexType>
|
||||
<xs:group ref="pathGroup"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="whiteListType">
|
||||
@@ -82,15 +84,17 @@
|
||||
</xs:complexType>
|
||||
<xs:group name="argumentsGroup">
|
||||
<xs:sequence>
|
||||
<xs:element name="array" type="arrayType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="integer" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="double" type="xs:double" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="null" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="object" type="objectType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="file" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="directory" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="boolean" type="xs:boolean" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="array" type="arrayType" />
|
||||
<xs:element name="integer" type="xs:integer" />
|
||||
<xs:element name="string" type="xs:string" />
|
||||
<xs:element name="double" type="xs:double" />
|
||||
<xs:element name="null" />
|
||||
<xs:element name="object" type="objectType" />
|
||||
<xs:element name="file" type="xs:anyURI" />
|
||||
<xs:element name="directory" type="xs:anyURI" />
|
||||
<xs:element name="boolean" type="xs:boolean" />
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:group>
|
||||
<xs:group name="argumentChoice">
|
||||
@@ -153,8 +157,10 @@
|
||||
</xs:complexType>
|
||||
<xs:group name="pathGroup">
|
||||
<xs:sequence>
|
||||
<xs:element name="directory" type="directoryFilterType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="file" type="fileFilterType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="directory" type="directoryFilterType"/>
|
||||
<xs:element name="file" type="fileFilterType"/>
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
</xs:group>
|
||||
<xs:complexType name="directoryFilterType">
|
||||
|
@@ -287,8 +287,6 @@ abstract class Assert
|
||||
/**
|
||||
* Asserts that a haystack contains only values of a given type.
|
||||
*
|
||||
* @param null|bool $isNativeType
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
@@ -349,8 +347,6 @@ abstract class Assert
|
||||
/**
|
||||
* Asserts that a haystack does not contain only values of a given type.
|
||||
*
|
||||
* @param null|bool $isNativeType
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
*/
|
||||
|
@@ -157,8 +157,6 @@ function assertAttributeNotContains($needle, string $haystackAttributeName, $hay
|
||||
/**
|
||||
* Asserts that a haystack contains only values of a given type.
|
||||
*
|
||||
* @param null|bool $isNativeType
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
@@ -197,8 +195,6 @@ function assertAttributeContainsOnly(string $type, string $haystackAttributeName
|
||||
/**
|
||||
* Asserts that a haystack does not contain only values of a given type.
|
||||
*
|
||||
* @param null|bool $isNativeType
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws ExpectationFailedException
|
||||
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
|
||||
|
@@ -75,38 +75,24 @@ class StringMatchesFormatDescription extends RegularExpression
|
||||
|
||||
private function createPatternFromFormat(string $string): string
|
||||
{
|
||||
$string = \preg_replace(
|
||||
$string = \strtr(
|
||||
\preg_quote($string, '/'),
|
||||
[
|
||||
'/(?<!%)%e/',
|
||||
'/(?<!%)%s/',
|
||||
'/(?<!%)%S/',
|
||||
'/(?<!%)%a/',
|
||||
'/(?<!%)%A/',
|
||||
'/(?<!%)%w/',
|
||||
'/(?<!%)%i/',
|
||||
'/(?<!%)%d/',
|
||||
'/(?<!%)%x/',
|
||||
'/(?<!%)%f/',
|
||||
'/(?<!%)%c/'
|
||||
],
|
||||
[
|
||||
\str_replace('\\', '\\\\', '\\' . \DIRECTORY_SEPARATOR),
|
||||
'[^\r\n]+',
|
||||
'[^\r\n]*',
|
||||
'.+',
|
||||
'.*',
|
||||
'\s*',
|
||||
'[+-]?\d+',
|
||||
'\d+',
|
||||
'[0-9a-fA-F]+',
|
||||
'[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?',
|
||||
'.'
|
||||
],
|
||||
\preg_quote($string, '/')
|
||||
'%%' => '%',
|
||||
'%e' => '\\' . \DIRECTORY_SEPARATOR,
|
||||
'%s' => '[^\r\n]+',
|
||||
'%S' => '[^\r\n]*',
|
||||
'%a' => '.+',
|
||||
'%A' => '.*',
|
||||
'%w' => '\s*',
|
||||
'%i' => '[+-]?\d+',
|
||||
'%d' => '\d+',
|
||||
'%x' => '[0-9a-fA-F]+',
|
||||
'%f' => '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?',
|
||||
'%c' => '.'
|
||||
]
|
||||
);
|
||||
|
||||
$string = \str_replace('%%', '%', $string);
|
||||
|
||||
return '/^' . $string . '$/s';
|
||||
}
|
||||
|
||||
|
@@ -102,8 +102,6 @@ class ExceptionWrapper extends Exception
|
||||
* Method to contain static originalException to exclude it from stacktrace to prevent the stacktrace contents,
|
||||
* which can be quite big, from being garbage-collected, thus blocking memory until shutdown.
|
||||
* Approach works both for var_dump() and var_export() and print_r()
|
||||
*
|
||||
* @param null|Throwable $exceptionToStore
|
||||
*/
|
||||
private function originalException(Throwable $exceptionToStore = null): ?Throwable
|
||||
{
|
||||
|
@@ -177,8 +177,6 @@ class MockBuilder
|
||||
/**
|
||||
* Specifies the subset of methods to mock. Default is to mock none of them.
|
||||
*
|
||||
* @param null|array $methods
|
||||
*
|
||||
* @return MockBuilder
|
||||
*/
|
||||
public function setMethods(array $methods = null)
|
||||
|
@@ -1447,7 +1447,8 @@ abstract class TestCase extends Assert implements Test, SelfDescribing
|
||||
protected function getMockFromWsdl($wsdlFile, $originalClassName = '', $mockClassName = '', array $methods = [], $callOriginalConstructor = true, array $options = []): MockObject
|
||||
{
|
||||
if ($originalClassName === '') {
|
||||
$originalClassName = \pathinfo(\basename(\parse_url($wsdlFile)['path']), \PATHINFO_FILENAME);
|
||||
$fileName = \pathinfo(\basename(\parse_url($wsdlFile)['path']), \PATHINFO_FILENAME);
|
||||
$originalClassName = \preg_replace('/[^a-zA-Z0-9_]/', '', $fileName);
|
||||
}
|
||||
|
||||
if (!\class_exists($originalClassName)) {
|
||||
|
@@ -30,7 +30,7 @@ class Version
|
||||
}
|
||||
|
||||
if (self::$version === null) {
|
||||
$version = new VersionId('7.3.1', \dirname(__DIR__, 2));
|
||||
$version = new VersionId('7.3.3', \dirname(__DIR__, 2));
|
||||
self::$version = $version->getVersion();
|
||||
}
|
||||
|
||||
|
68
vendor/phpunit/phpunit/src/Util/FileLoader.php
vendored
Normal file
68
vendor/phpunit/phpunit/src/Util/FileLoader.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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.
|
||||
*/
|
||||
final class FileLoader
|
||||
{
|
||||
/**
|
||||
* Checks if a PHP sourcecode file is readable. The sourcecode file is loaded through the load() method.
|
||||
*
|
||||
* As a fallback, PHP looks in the directory of the file executing the stream_resolve_include_path function.
|
||||
* We do not 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.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function checkAndLoad(string $filename): string
|
||||
{
|
||||
$includePathFilename = \stream_resolve_include_path($filename);
|
||||
$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.
|
||||
*/
|
||||
public static function load(string $filename): void
|
||||
{
|
||||
$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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
2
vendor/phpunit/phpunit/src/Util/Json.php
vendored
2
vendor/phpunit/phpunit/src/Util/Json.php
vendored
@@ -28,7 +28,7 @@ final class Json
|
||||
);
|
||||
}
|
||||
|
||||
return \json_encode($decodedJson, \JSON_PRETTY_PRINT);
|
||||
return \json_encode($decodedJson, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
/*
|
||||
|
46
vendor/phpunit/phpunit/src/Util/Log/TeamCity.php
vendored
46
vendor/phpunit/phpunit/src/Util/Log/TeamCity.php
vendored
@@ -60,9 +60,10 @@ class TeamCity extends ResultPrinter
|
||||
$this->printEvent(
|
||||
'testFailed',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($t),
|
||||
'details' => self::getDetails($t),
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($t),
|
||||
'details' => self::getDetails($t),
|
||||
'duration' => self::toMilliseconds($time),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -77,9 +78,10 @@ class TeamCity extends ResultPrinter
|
||||
$this->printEvent(
|
||||
'testFailed',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e)
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
'duration' => self::toMilliseconds($time),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -92,9 +94,10 @@ class TeamCity extends ResultPrinter
|
||||
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
|
||||
{
|
||||
$parameters = [
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
'name' => $test->getName(),
|
||||
'message' => self::getMessage($e),
|
||||
'details' => self::getDetails($e),
|
||||
'duration' => self::toMilliseconds($time),
|
||||
];
|
||||
|
||||
if ($e instanceof ExpectationFailedException) {
|
||||
@@ -129,7 +132,7 @@ class TeamCity extends ResultPrinter
|
||||
*/
|
||||
public function addIncompleteTest(Test $test, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->printIgnoredTest($test->getName(), $t);
|
||||
$this->printIgnoredTest($test->getName(), $t, $time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,21 +156,22 @@ class TeamCity extends ResultPrinter
|
||||
|
||||
if ($this->startedTestName !== $testName) {
|
||||
$this->startTest($test);
|
||||
$this->printIgnoredTest($testName, $t);
|
||||
$this->printIgnoredTest($testName, $t, $time);
|
||||
$this->endTest($test, $time);
|
||||
} else {
|
||||
$this->printIgnoredTest($testName, $t);
|
||||
$this->printIgnoredTest($testName, $t, $time);
|
||||
}
|
||||
}
|
||||
|
||||
public function printIgnoredTest($testName, \Throwable $t): void
|
||||
public function printIgnoredTest($testName, \Throwable $t, float $time): void
|
||||
{
|
||||
$this->printEvent(
|
||||
'testIgnored',
|
||||
[
|
||||
'name' => $testName,
|
||||
'message' => self::getMessage($t),
|
||||
'details' => self::getDetails($t),
|
||||
'name' => $testName,
|
||||
'message' => self::getMessage($t),
|
||||
'details' => self::getDetails($t),
|
||||
'duration' => self::toMilliseconds($time),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -273,7 +277,7 @@ class TeamCity extends ResultPrinter
|
||||
'testFinished',
|
||||
[
|
||||
'name' => $test->getName(),
|
||||
'duration' => (int) (\round($time, 2) * 1000)
|
||||
'duration' => self::toMilliseconds($time)
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -376,4 +380,12 @@ class TeamCity extends ResultPrinter
|
||||
|
||||
return $reflectionClass->getFileName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $time microseconds
|
||||
*/
|
||||
private static function toMilliseconds(float $time): int
|
||||
{
|
||||
return \round($time * 1000);
|
||||
}
|
||||
}
|
||||
|
@@ -54,6 +54,9 @@ final class NamePrettifier
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function prettifyTestCase(TestCase $test): string
|
||||
{
|
||||
$annotations = $test->getAnnotations();
|
||||
@@ -63,20 +66,16 @@ final class NamePrettifier
|
||||
$result = $annotations['method']['testdox'][0];
|
||||
|
||||
if (\strpos($result, '$') !== false) {
|
||||
$annotation = $annotations['method']['testdox'][0];
|
||||
$result = '';
|
||||
|
||||
$annotation = $annotations['method']['testdox'][0];
|
||||
$providedData = $this->mapTestMethodParameterNamesToProvidedDataValues($test);
|
||||
|
||||
foreach (\explode(' ', $annotation) as $word) {
|
||||
if (\strpos($word, '$') === 0) {
|
||||
$result .= $providedData[$word] . ' ';
|
||||
} else {
|
||||
$result .= $word . ' ';
|
||||
}
|
||||
}
|
||||
|
||||
$result = \trim($result);
|
||||
$result = \trim(
|
||||
\str_replace(
|
||||
\array_keys($providedData),
|
||||
$providedData,
|
||||
$annotation
|
||||
)
|
||||
);
|
||||
|
||||
$annotationWithPlaceholders = true;
|
||||
}
|
||||
@@ -151,6 +150,9 @@ final class NamePrettifier
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
private function mapTestMethodParameterNamesToProvidedDataValues(TestCase $test): array
|
||||
{
|
||||
$reflector = new \ReflectionMethod(\get_class($test), $test->getName(false));
|
||||
|
275
vendor/phpunit/phpunit/src/Util/Xml.php
vendored
Normal file
275
vendor/phpunit/phpunit/src/Util/Xml.php
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
<?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;
|
||||
|
||||
final 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 DOMDocument|string $actual
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function load($actual, bool $isHtml = false, string $filename = '', bool $xinclude = false, bool $strict = false): DOMDocument
|
||||
{
|
||||
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 !== '') {
|
||||
// Required 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.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function loadFile(string $filename, bool $isHtml = false, bool $xinclude = false, bool $strict = false): DOMDocument
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
public static function removeCharacterDataNodes(DOMNode $node): void
|
||||
{
|
||||
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 https://www.w3.org/TR/xml/#charsets
|
||||
*/
|
||||
public static function prepareString(string $string): string
|
||||
{
|
||||
return \preg_replace(
|
||||
'/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]/',
|
||||
'',
|
||||
\htmlspecialchars(
|
||||
self::convertToUtf8($string),
|
||||
\ENT_QUOTES
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Convert" a DOMElement object into a PHP variable.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
private static function convertToUtf8(string $string): string
|
||||
{
|
||||
if (!self::isUtf8($string)) {
|
||||
$string = \mb_convert_encoding($string, 'UTF-8');
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
private static function isUtf8(string $string): bool
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
@@ -84,4 +84,3 @@ class ArraySubsetTest extends ConstraintTestCase
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,13 +13,16 @@ use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
class StringMatchesFormatDescriptionTest extends ConstraintTestCase
|
||||
{
|
||||
public function testConstraintStringMatchesCharacter(): void
|
||||
public function testConstraintStringMatchesDirectorySeparator(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%c*');
|
||||
$constraint = new StringMatchesFormatDescription('*%e*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^\*.\*$/s"', $constraint->toString());
|
||||
$this->assertFalse($constraint->evaluate('*a*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('*' . \DIRECTORY_SEPARATOR . '*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*\\' . \DIRECTORY_SEPARATOR . '\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
@@ -28,17 +31,87 @@ class StringMatchesFormatDescriptionTest extends ConstraintTestCase
|
||||
$constraint = new StringMatchesFormatDescription('*%s*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate("*\n*", '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*foo 123 bar*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*[^\r\n]+\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesOptionalString(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%S*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('*', '', true));
|
||||
$this->assertFalse($constraint->evaluate("*\n*", '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*foo 123 bar*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('**', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*[^\r\n]*\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesAnything(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%a*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*foo 123 bar*', '', true));
|
||||
$this->assertTrue($constraint->evaluate("*\n*", '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*.+\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesOptionalAnything(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%A*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*foo 123 bar*', '', true));
|
||||
$this->assertTrue($constraint->evaluate("*\n*", '', true));
|
||||
$this->assertTrue($constraint->evaluate('**', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*.*\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesWhitespace(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%w*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*a*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('* *', '', true));
|
||||
$this->assertTrue($constraint->evaluate("*\t\n*", '', true));
|
||||
$this->assertTrue($constraint->evaluate('**', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*\s*\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesInteger(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%i*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*a*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*1.0*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('*0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*12*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*-1*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*+2*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*[+-]?\d+\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
@@ -48,7 +121,14 @@ class StringMatchesFormatDescriptionTest extends ConstraintTestCase
|
||||
$constraint = new StringMatchesFormatDescription('*%d*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*a*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*1.0*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*-1*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*+2*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('*0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*12*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*\d+\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
@@ -58,7 +138,17 @@ class StringMatchesFormatDescriptionTest extends ConstraintTestCase
|
||||
$constraint = new StringMatchesFormatDescription('*%x*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate('***', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*g*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*1.0*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*-1*', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*+2*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('*0f0f0f*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*12*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*a*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*[0-9a-fA-F]+\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
@@ -68,11 +158,91 @@ class StringMatchesFormatDescriptionTest extends ConstraintTestCase
|
||||
$constraint = new StringMatchesFormatDescription('*%f*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate('***', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*a*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('*1.0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*12*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*.1*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*1.*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*2e3*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*-2.34e-56*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*+2.34e+56*', '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesCharacter(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('*%c*');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('**', '', true));
|
||||
$this->assertFalse($constraint->evaluate('*ab*', '', true));
|
||||
|
||||
$this->assertTrue($constraint->evaluate('***', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*a*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*g*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*0*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('*2*', '', true));
|
||||
$this->assertTrue($constraint->evaluate('* *', '', true));
|
||||
$this->assertTrue($constraint->evaluate("*\n*", '', true));
|
||||
|
||||
$this->assertEquals('matches PCRE pattern "/^\*.\*$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesEscapedPercent(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('%%,%%e,%%s,%%S,%%a,%%A,%%w,%%i,%%d,%%x,%%f,%%c,%%Z,%%%%,%%');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('%%,%' . \DIRECTORY_SEPARATOR . ',%*,%*,%*,%*,% ,%0,%0,%0f0f0f,%1.0,%*,%%Z,%%%%,%%', '', true));
|
||||
$this->assertTrue($constraint->evaluate('%,%e,%s,%S,%a,%A,%w,%i,%d,%x,%f,%c,%Z,%%,%', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^%,%e,%s,%S,%a,%A,%w,%i,%d,%x,%f,%c,%Z,%%,%$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesEscapedPercentThenPlaceholder(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('%%%e,%%%s,%%%S,%%%a,%%%A,%%%w,%%%i,%%%d,%%%x,%%%f,%%%c');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('%%e,%%s,%%S,%%a,%%A,%%w,%%i,%%d,%%x,%%f,%%c', '', true));
|
||||
$this->assertTrue($constraint->evaluate('%' . \DIRECTORY_SEPARATOR . ',%*,%*,%*,%*,% ,%0,%0,%0f0f0f,%1.0,%*', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^%\\' . \DIRECTORY_SEPARATOR . ',%[^\r\n]+,%[^\r\n]*,%.+,%.*,%\s*,%[+-]?\d+,%\d+,%[0-9a-fA-F]+,%[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?,%.$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesSlash(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('/');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('\\/', '', true));
|
||||
$this->assertTrue($constraint->evaluate('/', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^\\/$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesBackslash(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('\\');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('\\\\', '', true));
|
||||
$this->assertTrue($constraint->evaluate('\\', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^\\\\$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesBackslashSlash(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription('\\/');
|
||||
|
||||
$this->assertFalse($constraint->evaluate('/', '', true));
|
||||
$this->assertTrue($constraint->evaluate('\\/', '', true));
|
||||
$this->assertEquals('matches PCRE pattern "/^\\\\\\/$/s"', $constraint->toString());
|
||||
$this->assertCount(1, $constraint);
|
||||
}
|
||||
|
||||
public function testConstraintStringMatchesNewline(): void
|
||||
{
|
||||
$constraint = new StringMatchesFormatDescription("\r\n");
|
||||
|
@@ -941,6 +941,18 @@ class MockObjectTest extends TestCase
|
||||
$this->assertEquals(\get_class($a), \get_class($b));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/sebastianbergmann/phpunit/issues/2573
|
||||
* @ticket 2573
|
||||
* @requires extension soap
|
||||
*/
|
||||
public function testCreateMockOfWsdlFileWithSpecialChars()
|
||||
{
|
||||
$mock = $this->getMockFromWsdl(__DIR__ . '/_fixture/Go ogle-Sea.rch.wsdl');
|
||||
|
||||
$this->assertStringStartsWith('Mock_GoogleSearch_', \get_class($mock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/156
|
||||
* @ticket 156
|
||||
|
@@ -19,13 +19,13 @@ PHPUnit %s by Sebastian Bergmann and contributors.
|
||||
|
||||
##teamcity[testStarted name='testPrintingChildException' locationHint='php_qn://%s%etests%e_files%eExceptionStackTest.php::\ExceptionStackTest::testPrintingChildException' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testPrintingChildException' message='Child exception|nmessage|nFailed asserting that two arrays are equal.|n--- Expected|n+++ Actual|n@@ @@|n Array (|n- 0 => 1|n+ 0 => 2|n )|n' details=' %s_files%eExceptionStackTest.php:%d|n |n Caused by|n message|n Failed asserting that two arrays are equal.|n --- Expected|n +++ Actual|n @@ @@|n Array (|n - 0 => 1|n + 0 => 2|n )|n |n %s_files%eExceptionStackTest.php:%d|n ' flowId='%d']
|
||||
##teamcity[testFailed name='testPrintingChildException' message='Child exception|nmessage|nFailed asserting that two arrays are equal.|n--- Expected|n+++ Actual|n@@ @@|n Array (|n- 0 => 1|n+ 0 => 2|n )|n' details=' %s_files%eExceptionStackTest.php:%d|n |n Caused by|n message|n Failed asserting that two arrays are equal.|n --- Expected|n +++ Actual|n @@ @@|n Array (|n - 0 => 1|n + 0 => 2|n )|n |n %s_files%eExceptionStackTest.php:%d|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testPrintingChildException' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testStarted name='testNestedExceptions' locationHint='php_qn://%s%etests%e_files%eExceptionStackTest.php::\ExceptionStackTest::testNestedExceptions' flowId='%d']
|
||||
|
||||
##teamcity[testFailed name='testNestedExceptions' message='Exception : One' details=' %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n ' flowId='%d']
|
||||
##teamcity[testFailed name='testNestedExceptions' message='Exception : One' details=' %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n ' duration='%d' flowId='%d']
|
||||
|
||||
##teamcity[testFinished name='testNestedExceptions' duration='%d' flowId='%d']
|
||||
|
||||
|
@@ -60,6 +60,7 @@ class JsonTest extends TestCase
|
||||
{
|
||||
return [
|
||||
['{"name":"John","age": "5"}', "{\n \"name\": \"John\",\n \"age\": \"5\"\n}"],
|
||||
['{"url":"https://www.example.com/"}', "{\n \"url\": \"https://www.example.com/\"\n}"],
|
||||
];
|
||||
}
|
||||
|
||||
|
119
vendor/phpunit/phpunit/tests/Util/XmlTest.php
vendored
Normal file
119
vendor/phpunit/phpunit/tests/Util/XmlTest.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?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\TestCase;
|
||||
|
||||
class XmlTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider charProvider
|
||||
*/
|
||||
public function testPrepareString(string $char): void
|
||||
{
|
||||
$e = null;
|
||||
|
||||
$escapedString = Xml::prepareString($char);
|
||||
$xml = "<?xml version='1.0' encoding='UTF-8' ?><tag>$escapedString</tag>";
|
||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||
|
||||
try {
|
||||
$dom->loadXML($xml);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
$this->assertNull(
|
||||
$e,
|
||||
\sprintf(
|
||||
'\PHPUnit\Util\Xml::prepareString("\x%02x") should not crash DomDocument',
|
||||
\ord($char)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function charProvider(): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
for ($i = 0; $i < 256; $i++) {
|
||||
$data[] = [\chr($i)];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function testLoadEmptyString(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('Could not load XML from empty string');
|
||||
|
||||
Xml::load('');
|
||||
}
|
||||
|
||||
public function testLoadArray(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('Could not load XML from array');
|
||||
|
||||
Xml::load([1, 2, 3]);
|
||||
}
|
||||
|
||||
public function testLoadBoolean(): void
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionMessage('Could not load XML from boolean');
|
||||
|
||||
Xml::load(false);
|
||||
}
|
||||
|
||||
public function testNestedXmlToVariable(): void
|
||||
{
|
||||
$xml = '<array><element key="a"><array><element key="b"><string>foo</string></element></array></element><element key="c"><string>bar</string></element></array>';
|
||||
$dom = new \DOMDocument;
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$expected = [
|
||||
'a' => [
|
||||
'b' => 'foo',
|
||||
],
|
||||
'c' => 'bar',
|
||||
];
|
||||
|
||||
$actual = Xml::xmlToVariable($dom->documentElement);
|
||||
|
||||
$this->assertSame($expected, $actual);
|
||||
}
|
||||
|
||||
public function testXmlToVariableCanHandleMultipleOfTheSameArgumentType(): void
|
||||
{
|
||||
$xml = '<object class="SampleClass"><arguments><string>a</string><string>b</string><string>c</string></arguments></object>';
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$expected = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
|
||||
|
||||
$actual = Xml::xmlToVariable($dom->documentElement);
|
||||
|
||||
$this->assertSame($expected, (array) $actual);
|
||||
}
|
||||
|
||||
public function testXmlToVariableCanConstructObjectsWithConstructorArgumentsRecursively(): void
|
||||
{
|
||||
$xml = '<object class="Exception"><arguments><string>one</string><integer>0</integer><object class="Exception"><arguments><string>two</string></arguments></object></arguments></object>';
|
||||
$dom = new \DOMDocument();
|
||||
$dom->loadXML($xml);
|
||||
|
||||
$actual = Xml::xmlToVariable($dom->documentElement);
|
||||
|
||||
$this->assertEquals('one', $actual->getMessage());
|
||||
$this->assertEquals('two', $actual->getPrevious()->getMessage());
|
||||
}
|
||||
}
|
198
vendor/phpunit/phpunit/tests/_files/Go ogle-Sea.rch.wsdl
vendored
Normal file
198
vendor/phpunit/phpunit/tests/_files/Go ogle-Sea.rch.wsdl
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- WSDL description of the Google Web APIs.
|
||||
The Google Web APIs are in beta release. All interfaces are subject to
|
||||
change as we refine and extend our APIs. Please see the terms of use
|
||||
for more information. -->
|
||||
|
||||
<!-- Revision 2002-08-16 -->
|
||||
|
||||
<definitions name="GoogleSearch"
|
||||
targetNamespace="urn:GoogleSearch"
|
||||
xmlns:typens="urn:GoogleSearch"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns="http://schemas.xmlsoap.org/wsdl/">
|
||||
|
||||
<!-- Types for search - result elements, directory categories -->
|
||||
|
||||
<types>
|
||||
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="urn:GoogleSearch">
|
||||
|
||||
<xsd:complexType name="GoogleSearchResult">
|
||||
<xsd:all>
|
||||
<xsd:element name="documentFiltering" type="xsd:boolean"/>
|
||||
<xsd:element name="searchComments" type="xsd:string"/>
|
||||
<xsd:element name="estimatedTotalResultsCount" type="xsd:int"/>
|
||||
<xsd:element name="estimateIsExact" type="xsd:boolean"/>
|
||||
<xsd:element name="resultElements" type="typens:ResultElementArray"/>
|
||||
<xsd:element name="searchQuery" type="xsd:string"/>
|
||||
<xsd:element name="startIndex" type="xsd:int"/>
|
||||
<xsd:element name="endIndex" type="xsd:int"/>
|
||||
<xsd:element name="searchTips" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategories" type="typens:DirectoryCategoryArray"/>
|
||||
<xsd:element name="searchTime" type="xsd:double"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElement">
|
||||
<xsd:all>
|
||||
<xsd:element name="summary" type="xsd:string"/>
|
||||
<xsd:element name="URL" type="xsd:string"/>
|
||||
<xsd:element name="snippet" type="xsd:string"/>
|
||||
<xsd:element name="title" type="xsd:string"/>
|
||||
<xsd:element name="cachedSize" type="xsd:string"/>
|
||||
<xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
|
||||
<xsd:element name="hostName" type="xsd:string"/>
|
||||
<xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
|
||||
<xsd:element name="directoryTitle" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="ResultElementArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ResultElement[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategoryArray">
|
||||
<xsd:complexContent>
|
||||
<xsd:restriction base="soapenc:Array">
|
||||
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:DirectoryCategory[]"/>
|
||||
</xsd:restriction>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="DirectoryCategory">
|
||||
<xsd:all>
|
||||
<xsd:element name="fullViewableName" type="xsd:string"/>
|
||||
<xsd:element name="specialEncoding" type="xsd:string"/>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
</types>
|
||||
|
||||
<!-- Messages for Google Web APIs - cached page, search, spelling. -->
|
||||
|
||||
<message name="doGetCachedPage">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="url" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGetCachedPageResponse">
|
||||
<part name="return" type="xsd:base64Binary"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestion">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="phrase" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doSpellingSuggestionResponse">
|
||||
<part name="return" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<!-- note, ie and oe are ignored by server; all traffic is UTF-8. -->
|
||||
|
||||
<message name="doGoogleSearch">
|
||||
<part name="key" type="xsd:string"/>
|
||||
<part name="q" type="xsd:string"/>
|
||||
<part name="start" type="xsd:int"/>
|
||||
<part name="maxResults" type="xsd:int"/>
|
||||
<part name="filter" type="xsd:boolean"/>
|
||||
<part name="restrict" type="xsd:string"/>
|
||||
<part name="safeSearch" type="xsd:boolean"/>
|
||||
<part name="lr" type="xsd:string"/>
|
||||
<part name="ie" type="xsd:string"/>
|
||||
<part name="oe" type="xsd:string"/>
|
||||
</message>
|
||||
|
||||
<message name="doGoogleSearchResponse">
|
||||
<part name="return" type="typens:GoogleSearchResult"/>
|
||||
</message>
|
||||
|
||||
<!-- Port for Google Web APIs, "GoogleSearch" -->
|
||||
|
||||
<portType name="GoogleSearchPort">
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<input message="typens:doGetCachedPage"/>
|
||||
<output message="typens:doGetCachedPageResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<input message="typens:doSpellingSuggestion"/>
|
||||
<output message="typens:doSpellingSuggestionResponse"/>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<input message="typens:doGoogleSearch"/>
|
||||
<output message="typens:doGoogleSearchResponse"/>
|
||||
</operation>
|
||||
|
||||
</portType>
|
||||
|
||||
|
||||
<!-- Binding for Google Web APIs - RPC, SOAP over HTTP -->
|
||||
|
||||
<binding name="GoogleSearchBinding" type="typens:GoogleSearchPort">
|
||||
<soap:binding style="rpc"
|
||||
transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
|
||||
<operation name="doGetCachedPage">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doSpellingSuggestion">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
|
||||
<operation name="doGoogleSearch">
|
||||
<soap:operation soapAction="urn:GoogleSearchAction"/>
|
||||
<input>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</input>
|
||||
<output>
|
||||
<soap:body use="encoded"
|
||||
namespace="urn:GoogleSearch"
|
||||
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
|
||||
</output>
|
||||
</operation>
|
||||
</binding>
|
||||
|
||||
<!-- Endpoint for Google Web APIs -->
|
||||
<service name="GoogleSearchService">
|
||||
<port name="GoogleSearchPort" binding="typens:GoogleSearchBinding">
|
||||
<soap:address location="http://api.google.com/search/beta2"/>
|
||||
</port>
|
||||
</service>
|
||||
|
||||
</definitions>
|
Reference in New Issue
Block a user