Skip to content

[VarDumper] Test ExceptionCaster excluding verbosity #23470

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

Merged
merged 1 commit into from
Jul 11, 2017
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\VarDumper\Tests\Caster;

use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\Caster\Caster;
use Symfony\Component\VarDumper\Caster\ExceptionCaster;
use Symfony\Component\VarDumper\Caster\FrameStub;
use Symfony\Component\VarDumper\Cloner\VarCloner;
Expand Down Expand Up @@ -43,9 +44,9 @@ public function testDefaultSettings()
#message: "foo"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 27
#line: 28
trace: {
%sExceptionCasterTest.php:27: {
%sExceptionCasterTest.php:28: {
: {
: return new \Exception(''.$msg);
: }
Expand All @@ -72,7 +73,7 @@ public function testSeek()

$expectedDump = <<<'EODUMP'
{
%sExceptionCasterTest.php:27: {
%sExceptionCasterTest.php:28: {
: {
: return new \Exception(''.$msg);
: }
Expand Down Expand Up @@ -101,9 +102,9 @@ public function testNoArgs()
#message: "1"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 27
#line: 28
trace: {
%sExceptionCasterTest.php:27: {
%sExceptionCasterTest.php:28: {
: {
: return new \Exception(''.$msg);
: }
Expand All @@ -129,9 +130,9 @@ public function testNoSrcContext()
#message: "1"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 27
#line: 28
trace: {
%sExceptionCasterTest.php: 27
%sExceptionCasterTest.php: 28
%sExceptionCasterTest.php: %d
%A
EODUMP;
Expand All @@ -157,10 +158,10 @@ public function testHtmlDump()
#<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
#<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
%d characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>"
#<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>27</span>
#<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>28</span>
<span class=sf-dump-meta>trace</span>: {<samp>
<span class=sf-dump-meta title="%sExceptionCasterTest.php
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>: <span class=sf-dump-num>27</span>
Stack level %d."><span class="sf-dump-ellipsis sf-dump-ellipsis-path">%s%eVarDumper</span><span class=sf-dump-ellipsis>%e</span>Tests%eCaster%eExceptionCasterTest.php</span>: <span class=sf-dump-num>28</span>
&hellip;%d
</samp>}
</samp>}
Expand Down Expand Up @@ -222,4 +223,20 @@ class: "__TwigTemplate_VarDumperFixture_u75a09"

$this->assertDumpMatchesFormat($expectedDump, $f);
}

public function testExcludeVerbosity()
{
$e = $this->getTestException('foo');

$expectedDump = <<<'EODUMP'
Exception {
#message: "foo"
#code: 0
#file: "%sExceptionCasterTest.php"
#line: 28
}
EODUMP;

$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
}
}