Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9525b9a

Browse files
committed
Add filter in VarDumperTestTrait
1 parent e9e19e7 commit 9525b9a

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

UPGRADE-4.0.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,39 @@ Validator
540540
changed to `true` as of 4.0. If you need the previous behaviour ensure to
541541
set the option to `false`.
542542

543+
VarDumper
544+
---------
545+
546+
* The `VarDumperTestTrait::assertDumpEquals()` method expects a 3rd `$context = null`
547+
argument and moves `$message = ''` argument at 4th position.
548+
549+
Before:
550+
551+
```php
552+
VarDumperTestTrait::assertDumpEquals($dump, $data, $message = '');
553+
```
554+
555+
After:
556+
557+
```php
558+
VarDumperTestTrait::assertDumpEquals($dump, $data, $filter = 0, $message = '');
559+
```
560+
561+
* The `VarDumperTestTrait::assertDumpMatchesFormat()` method expects a 3rd `$context = null`
562+
argument and moves `$message = ''` argument at 4th position.
563+
564+
Before:
565+
566+
```php
567+
VarDumperTestTrait::assertDumpMatchesFormat($dump, $data, $message = '');
568+
```
569+
570+
After:
571+
572+
```php
573+
VarDumperTestTrait::assertDumpMatchesFormat($dump, $data, $filter = 0, $message = '');
574+
```
575+
543576
Workflow
544577
--------
545578

src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,29 @@
1919
*/
2020
trait VarDumperTestTrait
2121
{
22-
public function assertDumpEquals($dump, $data, $message = '')
22+
public function assertDumpEquals($dump, $data, $filter = 0, $message = '')
2323
{
24-
$this->assertSame(rtrim($dump), $this->getDump($data), $message);
24+
if (is_string($filter)) {
25+
@trigger_error(sprintf('The $message argument of the %s() at 3rd position is deprecated since version 3.4 and will be moved at 4rd position in 4.0.', __METHOD__), E_USER_DEPRECATED);
26+
$message = $filter;
27+
$filter = 0;
28+
}
29+
30+
$this->assertSame(rtrim($dump), $this->getDump($data, null, $filter), $message);
2531
}
2632

27-
public function assertDumpMatchesFormat($dump, $data, $message = '')
33+
public function assertDumpMatchesFormat($dump, $data, $filter = 0, $message = '')
2834
{
29-
$this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data), $message);
35+
if (is_string($filter)) {
36+
@trigger_error(sprintf('The $message argument of the %s() at 3rd position is deprecated since version 3.4 and will be moved at 4rd position in 4.0.', __METHOD__), E_USER_DEPRECATED);
37+
$message = $filter;
38+
$filter = 0;
39+
}
40+
41+
$this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data, null, $filter), $message);
3042
}
3143

32-
protected function getDump($data, $key = null)
44+
protected function getDump($data, $key = null, $filter = 0)
3345
{
3446
$flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
3547
$flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
@@ -38,7 +50,7 @@ protected function getDump($data, $key = null)
3850
$cloner->setMaxItems(-1);
3951
$dumper = new CliDumper(null, null, $flags);
4052
$dumper->setColors(false);
41-
$data = $cloner->cloneVar($data)->withRefHandles(false);
53+
$data = $cloner->cloneVar($data, $filter)->withRefHandles(false);
4254
if (null !== $key && null === $data = $data->seek($key)) {
4355
return;
4456
}

0 commit comments

Comments
 (0)