Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy 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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
5b04647 to6b5ab90Comparejaviereguiluz commentedDec 6, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm all in for simplifications, but don't you think this is now too confusing? $this->assertDumpEquals(newToto('baz'),newToto('baz')); The two arguments are the same, I'm testing a dump but no dump is provided, etc. |
nicolas-grekas commentedDec 8, 2017
@javiereguiluz that's an real improvement over the current, where you have to maintain a dump for the expected side. |
Simperfit commentedDec 9, 2017
So I guess we could use this feature to improve the test in symfony ? |
fabpot commentedDec 11, 2017
I also like this for the better exception message you get instead of the standard PHPUnit one. |
fabpot commentedDec 11, 2017
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 | MITAt the moment, when using the `VarDumperTestTrait` in unit test, expecting data object is as follow:```phpclass 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 = <<<EOEXPECTEDProfiler\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
VarDumperTestTraitin unit test, expecting data object is as follow:The same test could be easily written like this with this change: