-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[VarDumper] Allow VarDumperTestTrait expectation to be non-scalar #25332
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
[VarDumper] Allow VarDumperTestTrait expectation to be non-scalar #25332
Conversation
5b04647
to
6b5ab90
Compare
I'm all in for simplifications, but don't you think this is now too confusing? $this->assertDumpEquals(new Toto('baz'), new Toto('baz')); The two arguments are the same, I'm testing a dump but no dump is provided, etc. |
@javiereguiluz that's an real improvement over the current, where you have to maintain a dump for the expected side. |
So I guess we could use this feature to improve the test in symfony ? |
I also like this for the better exception message you get instead of the standard PHPUnit one. |
Thank you @romainneutron. |
… non-scalar (romainneutron) This PR was merged into the 4.1-dev branch. Discussion ---------- [VarDumper] Allow VarDumperTestTrait expectation to be non-scalar | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT At the moment, when using the `VarDumperTestTrait` in unit test, expecting data object is as follow: ```php class Toto { private $foo; public function __construct($foo) { $this->foo = $foo; } } class MyTest extends \PHPUnit_Framework_TestCase { use Symfony\Component\VarDumper\Test\VarDumperTestTrait; public function dummyTest() { $expected = <<<EOEXPECTED Profiler\Tests\Model\CallGraph\Toto { -foo: "baz" } EOEXPECTED; $this->assertDumpEquals($expected, new Toto('baz')); } } ``` The same test could be easily written like this with this change: ```php public function dummyTest() { $this->assertDumpEquals(new Toto('baz'), new Toto('baz')); } ``` Commits ------- 6b5ab90 [VarDumper] Allow VarDumperTestTrait expectation to be non-scalar
At the moment, when using the
VarDumperTestTrait
in unit test, expecting data object is as follow:The same test could be easily written like this with this change: