Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #19289 [VarDumper] Dumping exceptions is now more compact (ni…
…colas-grekas) This PR was merged into the 3.2-dev branch. Discussion ---------- [VarDumper] Dumping exceptions is now more compact | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - Before: ![before](https://cloud.githubusercontent.com/assets/243674/16578686/2c7285b0-429c-11e6-9139-293e0c899d43.png) Commits ------- 19e9cbe [VarDumper] Dumping exceptions is now more compact
- Loading branch information
Showing
8 changed files
with
207 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\VarDumper\Tests\Caster; | ||
|
||
use Symfony\Component\VarDumper\Caster\ExceptionCaster; | ||
use Symfony\Component\VarDumper\Test\VarDumperTestTrait; | ||
|
||
class ExceptionCasterTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
use VarDumperTestTrait; | ||
|
||
private function getTestException() | ||
{ | ||
return new \Exception('foo'); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
ExceptionCaster::$srcContext = 1; | ||
ExceptionCaster::$traceArgs = true; | ||
} | ||
|
||
public function testDefaultSettings() | ||
{ | ||
$e = $this->getTestException(1); | ||
|
||
$expectedDump = <<<'EODUMP' | ||
Exception { | ||
#message: "foo" | ||
#code: 0 | ||
#file: "%sExceptionCasterTest.php" | ||
#line: 23 | ||
-trace: { | ||
%d. %sExceptionCasterTest.php: { | ||
22: { | ||
23: return new \Exception('foo'); | ||
24: } | ||
} | ||
%d. %sExceptionCasterTest.php: { | ||
%d: { | ||
%d: $e = $this->getTestException(1); | ||
%d: | ||
args: { | ||
1 | ||
} | ||
} | ||
%A | ||
EODUMP; | ||
|
||
$this->assertDumpMatchesFormat($expectedDump, $e); | ||
} | ||
|
||
public function testNoArgs() | ||
{ | ||
$e = $this->getTestException(1); | ||
ExceptionCaster::$traceArgs = false; | ||
|
||
$expectedDump = <<<'EODUMP' | ||
Exception { | ||
#message: "foo" | ||
#code: 0 | ||
#file: "%sExceptionCasterTest.php" | ||
#line: 23 | ||
-trace: { | ||
%d. %sExceptionCasterTest.php: { | ||
22: { | ||
23: return new \Exception('foo'); | ||
24: } | ||
} | ||
%d. %sExceptionCasterTest.php: { | ||
%d: { | ||
%d: $e = $this->getTestException(1); | ||
%d: ExceptionCaster::$traceArgs = false; | ||
} | ||
%A | ||
EODUMP; | ||
|
||
$this->assertDumpMatchesFormat($expectedDump, $e); | ||
} | ||
|
||
public function testNoSrcContext() | ||
{ | ||
$e = $this->getTestException(1); | ||
ExceptionCaster::$srcContext = -1; | ||
|
||
$expectedDump = <<<'EODUMP' | ||
Exception { | ||
#message: "foo" | ||
#code: 0 | ||
#file: "%sExceptionCasterTest.php" | ||
#line: 23 | ||
-trace: { | ||
%d. %sExceptionCasterTest.php: 23 | ||
%d. %sExceptionCasterTest.php: %d | ||
%A | ||
EODUMP; | ||
|
||
$this->assertDumpMatchesFormat($expectedDump, $e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.