Larval framework upated to v5.6.33

Updated laravel frameowrk version to as suggested for security patch update which was released in v5.6.30
This commit is contained in:
Manish Verma
2018-08-15 18:38:24 +05:30
parent 5d3ffdf379
commit 8148bbd920
319 changed files with 647 additions and 1078 deletions

View File

@@ -2,7 +2,7 @@
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.10] - 2018-MM-DD
## [6.5.10] - 2018-08-03
### Fixed

View File

@@ -2,6 +2,17 @@
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.1] - 2018-08-07
### Changed
* Reverted [#3161](https://github.com/sebastianbergmann/phpunit/pull/3161) (because of [#3240](https://github.com/sebastianbergmann/phpunit/issues/3240)): Support for indexed arrays in `PHPUnit\Framework\Constraint\ArraySubset`
### Fixed
* Fixed [#3237](https://github.com/sebastianbergmann/phpunit/issues/3237): Result caching enabled by default
* Fixed [#3240](https://github.com/sebastianbergmann/phpunit/issues/3240): `assertArraySubset()` does not work as expected
## [7.3.0] - 2018-08-03
### Added
@@ -26,5 +37,6 @@ 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.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

View File

@@ -4,16 +4,16 @@ PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of
[![Latest Stable Version](https://img.shields.io/packagist/v/phpunit/phpunit.svg?style=flat-square)](https://packagist.org/packages/phpunit/phpunit)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/)
[![Build Status](https://img.shields.io/travis/sebastianbergmann/7.2/master.svg?style=flat-square)](https://phpunit.de/build-status.html)
[![Build Status](https://img.shields.io/travis/sebastianbergmann/phpunit/7.3.svg?style=flat-square)](https://phpunit.de/build-status.html)
## Installation
We distribute a [PHP Archive (PHAR)](https://php.net/phar) that has all required (as well as some optional) dependencies of PHPUnit 7.3 bundled in a single file:
```bash
$ wget https://phar.phpunit.de/phpunit-7.2.phar
$ wget https://phar.phpunit.de/phpunit-7.3.phar
$ php phpunit-7.2.phar --version
$ php phpunit-7.3.phar --version
```
Alternatively, you may use [Composer](https://getcomposer.org/) to download and install PHPUnit as well as its dependencies. Please refer to the "[Getting Started](https://phpunit.de/getting-started-with-phpunit.html)" guide for details on how to install PHPUnit.

0
vendor/phpunit/phpunit/phpunit vendored Normal file → Executable file
View File

View File

@@ -223,7 +223,7 @@
<xs:attribute name="backupGlobals" type="xs:boolean" default="false"/>
<xs:attribute name="backupStaticAttributes" type="xs:boolean" default="false"/>
<xs:attribute name="bootstrap" type="xs:anyURI"/>
<xs:attribute name="cacheResult" type="xs:boolean"/>
<xs:attribute name="cacheResult" type="xs:boolean" default="false"/>
<xs:attribute name="cacheResultFile" type="xs:anyURI"/>
<xs:attribute name="cacheTokens" type="xs:boolean"/>
<xs:attribute name="colors" type="xs:boolean" default="false"/>

View File

@@ -62,12 +62,13 @@ class ArraySubset extends Constraint
$other = $this->toArray($other);
$this->subset = $this->toArray($this->subset);
$intersect = $this->arrayIntersectRecursive($other, $this->subset);
$patched = \array_replace_recursive($other, $this->subset);
$this->deepSort($intersect);
$this->deepSort($this->subset);
$result = $this->compare($intersect, $this->subset);
if ($this->strict) {
$result = $other === $patched;
} else {
$result = $other == $patched;
}
if ($returnResult) {
return $result;
@@ -75,9 +76,9 @@ class ArraySubset extends Constraint
if (!$result) {
$f = new ComparisonFailure(
$this->subset,
$patched,
$other,
\print_r($this->subset, true),
\print_r($patched, true),
\print_r($other, true)
);
@@ -127,86 +128,4 @@ class ArraySubset extends Constraint
// Keep BC even if we know that array would not be the expected one
return (array) $other;
}
private function isAssociative(array $array): bool
{
return \array_reduce(
\array_keys($array),
function (bool $carry, $key): bool {
return $carry || \is_string($key);
},
false
);
}
private function compare($first, $second): bool
{
return $this->strict ? $first === $second : $first == $second;
}
private function deepSort(array &$array): void
{
foreach ($array as &$value) {
if (\is_array($value)) {
$this->deepSort($value);
}
}
unset($value);
if ($this->isAssociative($array)) {
\ksort($array);
} else {
\sort($array);
}
}
private function arrayIntersectRecursive(array $array, array $subset): array
{
$intersect = [];
if ($this->isAssociative($subset)) {
// If the subset is an associative array, get the intersection while
// preserving the keys.
foreach ($subset as $key => $subset_value) {
if (\array_key_exists($key, $array)) {
$array_value = $array[$key];
if (\is_array($subset_value) && \is_array($array_value)) {
$intersect[$key] = $this->arrayIntersectRecursive($array_value, $subset_value);
} elseif ($this->compare($subset_value, $array_value)) {
$intersect[$key] = $array_value;
}
}
}
} else {
// If the subset is an indexed array, loop over all entries in the
// haystack and check if they match the ones in the subset.
foreach ($array as $array_value) {
if (\is_array($array_value)) {
foreach ($subset as $key => $subset_value) {
if (\is_array($subset_value)) {
$recursed = $this->arrayIntersectRecursive($array_value, $subset_value);
if (!empty($recursed)) {
$intersect[$key] = $recursed;
break;
}
}
}
} else {
foreach ($subset as $key => $subset_value) {
if (!\is_array($subset_value) && $this->compare($subset_value, $array_value)) {
$intersect[$key] = $array_value;
break;
}
}
}
}
}
return $intersect;
}
}

View File

@@ -30,7 +30,7 @@ class Version
}
if (self::$version === null) {
$version = new VersionId('7.3.0', \dirname(__DIR__, 2));
$version = new VersionId('7.3.1', \dirname(__DIR__, 2));
self::$version = $version->getVersion();
}

View File

@@ -1157,7 +1157,7 @@ class TestRunner extends BaseTestRunner
$arguments['backupStaticAttributes'] = $arguments['backupStaticAttributes'] ?? null;
$arguments['beStrictAboutChangesToGlobalState'] = $arguments['beStrictAboutChangesToGlobalState'] ?? null;
$arguments['beStrictAboutResourceUsageDuringSmallTests'] = $arguments['beStrictAboutResourceUsageDuringSmallTests'] ?? false;
$arguments['cacheResult'] = $arguments['cacheResult'] ?? true;
$arguments['cacheResult'] = $arguments['cacheResult'] ?? false;
$arguments['cacheTokens'] = $arguments['cacheTokens'] ?? false;
$arguments['colors'] = $arguments['colors'] ?? ResultPrinter::COLOR_DEFAULT;
$arguments['columns'] = $arguments['columns'] ?? 80;

View File

@@ -1,68 +0,0 @@
<?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];
}
}
}
}

View File

@@ -1,275 +0,0 @@
<?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;
}
}

View File

@@ -158,17 +158,13 @@ class AssertTest extends TestCase
'd' => ['a2' => ['a3' => 'item a3', 'b3' => 'item b3']]
];
$this->assertArraySubset(['a' => 'item a'], $array);
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $array);
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $array);
$this->assertArraySubset(['b' => 'item b', 'd' => ['a2' => ['b3' => 'item b3']]], $array);
$arrayAccessData = new \ArrayObject($array);
$this->assertArraySubset(['a' => 'item a'], $arrayAccessData);
$this->assertArraySubset(['a' => 'item a', 'c' => ['a2' => 'item a2']], $arrayAccessData);
$this->assertArraySubset(['a' => 'item a', 'd' => ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
$this->assertArraySubset(['b' => 'item b', 'd' => ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
try {
$this->assertArraySubset(['a' => 'bad value'], $array);
@@ -184,39 +180,6 @@ class AssertTest extends TestCase
$this->fail();
}
public function testAssertArraySubsetWithIndexedArrays(): void
{
$array = [
'item a',
'item b',
['a2' => 'item a2', 'b2' => 'item b2'],
['a2' => ['a3' => 'item a3', 'b3' => 'item b3']]
];
$this->assertArraySubset(['item a', ['a2' => 'item a2']], $array);
$this->assertArraySubset(['item a', ['a2' => ['b3' => 'item b3']]], $array);
$this->assertArraySubset(['item b', ['a2' => ['b3' => 'item b3']]], $array);
$arrayAccessData = new \ArrayObject($array);
$this->assertArraySubset(['item a', ['a2' => 'item a2']], $arrayAccessData);
$this->assertArraySubset(['item a', ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
$this->assertArraySubset(['item b', ['a2' => ['b3' => 'item b3']]], $arrayAccessData);
try {
$this->assertArraySubset(['bad value'], $array);
} catch (AssertionFailedError $e) {
}
try {
$this->assertArraySubset([['a2' => ['bad index' => 'item b3']]], $array);
} catch (AssertionFailedError $e) {
return;
}
$this->fail();
}
public function testAssertArraySubsetWithDeepNestedArrays(): void
{
$array = [

View File

@@ -16,146 +16,30 @@ class ArraySubsetTest extends ConstraintTestCase
public static function evaluateDataProvider()
{
return [
'loose associative array subset and array other' => [
'loose array subset and array other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => false
],
'strict associative array subset and array other' => [
'strict array subset and array other' => [
'expected' => false,
'subset' => ['bar' => 0],
'other' => ['foo' => '', 'bar' => '0'],
'strict' => true
],
'loose associative array subset and ArrayObject other' => [
'loose array subset and ArrayObject other' => [
'expected' => true,
'subset' => ['bar' => 0],
'other' => new \ArrayObject(['foo' => '', 'bar' => '0']),
'strict' => false
],
'strict associative ArrayObject subset and array other' => [
'strict ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject(['bar' => 0]),
'other' => ['foo' => '', 'bar' => 0],
'strict' => true
],
'loose indexed array subset and array other' => [
'expected' => true,
'subset' => [0],
'other' => ['', '0'],
'strict' => false
],
'strict indexed array subset and array other' => [
'expected' => false,
'subset' => [0],
'other' => ['', '0'],
'strict' => true
],
'loose indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [0],
'other' => new \ArrayObject(['', '0']),
'strict' => false
],
'strict indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([0]),
'other' => ['', 0],
'strict' => true
],
'loose unordered indexed array subset and array other' => [
'expected' => true,
'subset' => [0, '1'],
'other' => ['1', '2', '0'],
'strict' => false
],
'strict unordered indexed array subset and array other' => [
'expected' => false,
'subset' => [0, '1'],
'other' => ['1', '2', '0'],
'strict' => true
],
'loose unordered indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [0, '1'],
'other' => new \ArrayObject(['1', '2', '0']),
'strict' => false
],
'strict unordered indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([0, '1']),
'other' => ['1', '2', 0],
'strict' => true
],
'loose unordered multidimensional indexed array subset and array other' => [
'expected' => true,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => false
],
'strict unordered multidimensional indexed array subset and array other' => [
'expected' => false,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => true
],
'loose unordered multidimensional indexed array subset and ArrayObject other' => [
'expected' => true,
'subset' => [
[[3, 4], 2],
'10',
],
'other' => new \ArrayObject([
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
]),
'strict' => false
],
'strict unordered multidimensional indexed ArrayObject subset and array other' => [
'expected' => true,
'subset' => new \ArrayObject([
[[3, 4], '2'],
'10',
]),
'other' => [
0 => '1',
'a' => [
'aa' => '2',
'ab' => [5, 4, 3],
'ac' => 10,
],
'b' => '10',
],
'strict' => true
],
];
}
@@ -200,3 +84,4 @@ class ArraySubsetTest extends ConstraintTestCase
}
}
}

View File

@@ -8,9 +8,10 @@ file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../_files/Multi
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--debug';
$_SERVER['argv'][3] = '--order-by=defects';
$_SERVER['argv'][4] = '--cache-result-file=' . $tmpResultCache;
$_SERVER['argv'][5] = 'MultiDependencyTest';
$_SERVER['argv'][6] = __DIR__ . '/../_files/MultiDependencyTest.php';
$_SERVER['argv'][4] = '--cache-result';
$_SERVER['argv'][5] = '--cache-result-file=' . $tmpResultCache;
$_SERVER['argv'][6] = 'MultiDependencyTest';
$_SERVER['argv'][7] = __DIR__ . '/../_files/MultiDependencyTest.php';
require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();

View File

@@ -1,119 +0,0 @@
<?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());
}
}