Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to limit export of arrays #5869

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"sebastian/comparator": "^6.0",
"sebastian/diff": "^6.0",
"sebastian/environment": "^7.0",
"sebastian/exporter": "^6.1",
"sebastian/exporter": "^6.1.2",
"sebastian/global-state": "^7.0",
"sebastian/object-enumerator": "^6.0",
"sebastian/type": "^5.0",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<xs:attribute name="displayDetailsOnTestsThatTriggerErrors" type="xs:boolean" default="false"/>
<xs:attribute name="displayDetailsOnTestsThatTriggerNotices" type="xs:boolean" default="false"/>
<xs:attribute name="displayDetailsOnTestsThatTriggerWarnings" type="xs:boolean" default="false"/>
<xs:attribute name="shortenArraysForExportThreshold" type="xs:integer" default="0"/>
</xs:attributeGroup>
<xs:group name="configGroup">
<xs:all>
Expand Down
4 changes: 2 additions & 2 deletions src/Event/Emitter/DispatchingEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use PHPUnit\Event\TestSuite\Started as TestSuiteStarted;
use PHPUnit\Event\TestSuite\TestSuite;
use PHPUnit\TextUI\Configuration\Configuration;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -578,11 +578,11 @@
*/
public function testCreatedTestProxy(string $className, array $constructorArguments): void
{
$this->dispatcher->dispatch(

Check warning on line 581 in src/Event/Emitter/DispatchingEmitter.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ */ public function testCreatedTestProxy(string $className, array $constructorArguments): void { - $this->dispatcher->dispatch(new Test\TestProxyCreated($this->telemetryInfo(), $className, Exporter::export($constructorArguments))); + } /** * @psalm-param class-string $className
new Test\TestProxyCreated(
$this->telemetryInfo(),
$className,
(new Exporter)->export($constructorArguments),
Exporter::export($constructorArguments),
),
);
}
Expand Down
7 changes: 3 additions & 4 deletions src/Event/Value/Test/TestMethodBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use PHPUnit\Event\TestData\TestDataCollection;
use PHPUnit\Framework\TestCase;
use PHPUnit\Metadata\Parser\Registry as MetadataRegistry;
use PHPUnit\Util\Exporter;
use PHPUnit\Util\Reflection;
use SebastianBergmann\Exporter\Exporter;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -60,7 +60,6 @@ public static function fromCallStack(): TestMethod

private static function dataFor(TestCase $testCase): TestDataCollection
{
$exporter = new Exporter;
$testData = [];

if ($testCase->usesDataProvider()) {
Expand All @@ -72,14 +71,14 @@ private static function dataFor(TestCase $testCase): TestDataCollection

$testData[] = DataFromDataProvider::from(
$dataSetName,
$exporter->export($testCase->providedData()),
Exporter::export($testCase->providedData()),
$testCase->dataSetAsStringWithData(),
);
}

if ($testCase->hasDependencyInput()) {
$testData[] = DataFromTestDependency::from(
$exporter->export($testCase->dependencyInput()),
Exporter::export($testCase->dependencyInput()),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Cardinality/GreaterThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;

use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand All @@ -28,7 +28,7 @@ public function __construct(mixed $value)
*/
public function toString(): string
{
return 'is greater than ' . (new Exporter)->export($this->value);
return 'is greater than ' . Exporter::export($this->value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Cardinality/LessThan.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
namespace PHPUnit\Framework\Constraint;

use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand All @@ -28,7 +28,7 @@ public function __construct(mixed $value)
*/
public function toString(): string
{
return 'is less than ' . (new Exporter)->export($this->value);
return 'is less than ' . Exporter::export($this->value);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/Constraint/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use Countable;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\SelfDescribing;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Exporter\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -123,7 +123,7 @@ protected function additionalFailureDescription(mixed $other): string
*/
protected function failureDescription(mixed $other): string
{
return (new Exporter)->export($other) . ' ' . $this->toString();
return Exporter::export($other) . ' ' . $this->toString();
}

/**
Expand Down Expand Up @@ -163,7 +163,7 @@ protected function failureDescriptionInContext(Operator $operator, mixed $role,
return '';
}

return (new Exporter)->export($other) . ' ' . $string;
return Exporter::export($other) . ' ' . $string;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Equality/IsEqual.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use function str_contains;
use function trim;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Exporter\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -97,7 +97,7 @@ public function toString(): string

return sprintf(
'is equal to %s%s',
(new Exporter)->export($this->value),
Exporter::export($this->value),
$delta,
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Equality/IsEqualCanonicalizing.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use function str_contains;
use function trim;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Exporter\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -97,7 +97,7 @@ public function toString(): string

return sprintf(
'is equal to %s',
(new Exporter)->export($this->value),
Exporter::export($this->value),
);
}
}
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Equality/IsEqualIgnoringCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use function str_contains;
use function trim;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Exporter\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -98,7 +98,7 @@ public function toString(): string

return sprintf(
'is equal to %s',
(new Exporter)->export($this->value),
Exporter::export($this->value),
);
}
}
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Equality/IsEqualWithDelta.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use function sprintf;
use function trim;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Comparator\Factory as ComparatorFactory;
use SebastianBergmann\Exporter\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -85,7 +85,7 @@ public function toString(): string
{
return sprintf(
'is equal to %s with delta <%F>',
(new Exporter)->export($this->value),
Exporter::export($this->value),
$this->delta,
);
}
Expand Down
8 changes: 3 additions & 5 deletions src/Framework/Constraint/Exception/ExceptionCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace PHPUnit\Framework\Constraint;

use function sprintf;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -46,12 +46,10 @@ protected function matches(mixed $other): bool
*/
protected function failureDescription(mixed $other): string
{
$exporter = new Exporter;

return sprintf(
'%s is equal to expected exception code %s',
$exporter->export($other),
$exporter->export($this->expectedCode),
Exporter::export($other),
Exporter::export($this->expectedCode),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use function sprintf;
use function str_contains;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand All @@ -31,7 +31,7 @@ public function toString(): string
return 'exception message is empty';
}

return 'exception message contains ' . (new Exporter)->export($this->expectedMessage);
return 'exception message contains ' . Exporter::export($this->expectedMessage);
}

protected function matches(mixed $other): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function preg_match;
use function sprintf;
use Exception;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
Expand All @@ -28,7 +28,7 @@ public function __construct(string $regularExpression)

public function toString(): string
{
return 'exception message matches ' . (new Exporter)->export($this->regularExpression);
return 'exception message matches ' . Exporter::export($this->regularExpression);
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/Framework/Constraint/IsIdentical.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use function is_string;
use function sprintf;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Util\Exporter;
use SebastianBergmann\Comparator\ComparisonFailure;
use SebastianBergmann\Exporter\Exporter;
use UnitEnum;

/**
Expand Down Expand Up @@ -67,13 +67,11 @@ public function evaluate(mixed $other, string $description = '', bool $returnRes

// if both values are array or enums, make sure a diff is generated
if ((is_array($this->value) && is_array($other)) || ($this->value instanceof UnitEnum && $other instanceof UnitEnum)) {
$exporter = new Exporter;

$f = new ComparisonFailure(
$this->value,
$other,
$exporter->export($this->value),
$exporter->export($other),
Exporter::export($this->value),
Exporter::export($other),
);
}

Expand All @@ -93,7 +91,7 @@ public function toString(): string
$this->value::class . '"';
}

return 'is identical to ' . (new Exporter)->export($this->value);
return 'is identical to ' . Exporter::export($this->value);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/String/StringContains.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function str_contains;
use function strlen;
use function strtr;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand Down Expand Up @@ -58,9 +58,9 @@
);
}

public function failureDescription(mixed $other): string

Check warning on line 61 in src/Framework/Constraint/String/StringContains.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ } return sprintf('contains "%s" [%s](length: %s)', $needle, $this->getDetectedEncoding($needle), strlen($needle)); } - public function failureDescription(mixed $other): string + protected function failureDescription(mixed $other): string { $stringifiedHaystack = Exporter::export($other); $haystackEncoding = $this->getDetectedEncoding($other);
{
$stringifiedHaystack = (new Exporter)->export($other);
$stringifiedHaystack = Exporter::export($other);
$haystackEncoding = $this->getDetectedEncoding($other);
$haystackLength = $this->getHaystackLength($other);

Expand Down
4 changes: 2 additions & 2 deletions src/Framework/Constraint/Traversable/ArrayHasKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function array_key_exists;
use function is_array;
use ArrayAccess;
use SebastianBergmann\Exporter\Exporter;
use PHPUnit\Util\Exporter;

/**
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Expand All @@ -31,7 +31,7 @@ public function __construct(int|string $key)
*/
public function toString(): string
{
return 'has the key ' . (new Exporter)->export($this->key);
return 'has the key ' . Exporter::export($this->key);
}

/**
Expand Down
Loading