Add helper debugging/rendering function for (unit) tests #1439
Replies: 2 comments
-
|
I think this would
So it gets my vote.
I'd prefer something like
I think It could be initially added to the interface, with implementing classes throwing a
This looks perfect for quickly digging into the results of the parsing for testing.
Not just readability. It may make it easier to test for a class name without caring about its namespace.
That returns a string (which is not good for testing, as pointed out in the OP). We're talking about returning an array here.
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your thoughts! I've created #1440 for this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
One big hurdle for adding more tests and for refactoring the existing tests is that we currently cannot check easily what the result of parsing some CSS is. I've thought about how we could improve this.
At the moment, we either check what
render()returns (which also tests the rendering code and is dependent on the passed output format), or we do a big salad of multiple assertions, including multipleassertInstanceOfcalls for the subject's children..I'd like to make this easier. For this, I suggest we add an
@internalmethoddebugForTesting()(suggestions for a better name are welcome) and add it to theCSSElement(orRenderable) interface.This method returns an object's class, its relevant data and recursively its children.
The return value is an
arrayas this avoids the problem of multiline strings and long lines thatstrings have. Also, PHPUnit is quite good at displaying differences in arrays in a readable manner.For example, the multi-assertion test then could work on an array like this instead (manually written, not tested):
Unlike
var_export, this returned representation can hide some irrelevant internal details and shorten the output.WDYT, @sabberworm, @JakeQZ?
Beta Was this translation helpful? Give feedback.
All reactions