Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5b04647

Browse filesBrowse files
committed
[VarDumper] Allow VarDumperTestTrait expectation to be non-scalar
1 parent 3ce9c29 commit 5b04647
Copy full SHA for 5b04647

File tree

2 files changed

+18
-4
lines changed
Filter options

2 files changed

+18
-4
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Test/VarDumperTestTrait.php
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
*/
2020
trait VarDumperTestTrait
2121
{
22-
public function assertDumpEquals($dump, $data, $filter = 0, $message = '')
22+
public function assertDumpEquals($expected, $data, $filter = 0, $message = '')
2323
{
24-
$this->assertSame(rtrim($dump), $this->getDump($data, null, $filter), $message);
24+
$this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
2525
}
2626

27-
public function assertDumpMatchesFormat($dump, $data, $filter = 0, $message = '')
27+
public function assertDumpMatchesFormat($expected, $data, $filter = 0, $message = '')
2828
{
29-
$this->assertStringMatchesFormat(rtrim($dump), $this->getDump($data, null, $filter), $message);
29+
$this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message);
3030
}
3131

3232
protected function getDump($data, $key = null, $filter = 0)
@@ -45,4 +45,13 @@ protected function getDump($data, $key = null, $filter = 0)
4545

4646
return rtrim($dumper->dump($data, true));
4747
}
48+
49+
private function prepareExpectation($expected, $filter)
50+
{
51+
if (!is_string($expected)) {
52+
$expected = $this->getDump($expected, null, $filter);
53+
}
54+
55+
return rtrim($expected);
56+
}
4857
}

‎src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Tests/Test/VarDumperTestTraitTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public function testItComparesLargeData()
3838

3939
$this->assertDumpEquals($expected, $data);
4040
}
41+
42+
public function testAllowsNonScalarExpectation()
43+
{
44+
$this->assertDumpEquals(new \ArrayObject(['bim' => 'bam']), new \ArrayObject(['bim' => 'bam']));
45+
}
4146
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.