Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5773 +/- ##
============================================
- Coverage 90.14% 90.06% -0.08%
- Complexity 6585 6598 +13
============================================
Files 693 696 +3
Lines 19943 19966 +23
============================================
+ Hits 17977 17983 +6
- Misses 1966 1983 +17 ☔ View full report in Codecov by Sentry. |
|
while I agree that a configurable exporter can have benefit for specific use-cases, I would expect the "default exporter" to be fast enough, so I don't need to structure my unit test arround a "limitation" of phpunit, that objects/arrays in data-providers are not efficient enough. no offense on this end - just my point of view. |
None taken.
Sure! As I said before, I am not doing this for performance. sebastianbergmann/exporter#55 is likely a more appropriate solution for performance issues. |
|
Isn't it better architecture here to have a Factory where one can add multiple exporters (in a config file, probably? or a bootstrap file?) that are called for each type? E.g. class ExporterFactory
{
public function addExporter(ExporterInterface $exporter) { ... }
public function getExporterForValue(mixed $value) {
foreach($this->exporters as $exporter) {
if($exporter->supports($value)) return $exporter;
}
return $this->defaultExporter;
}
}That way doctrine can create their own exporter, I can make my own, etc. |
|
@BladeMF I wanted to keep this as simple as possible, but will ponder your suggestion. |
|
In this implementation I have two questions:
|
That is what I mean by "Make alternative implementation of PHPUnit\Util\Exporter configurable via PHPUnit's XML configuration file" in #5773 (comment).
Currently not, but I will ponder that. |
|
Thanks for looking into it. |
|
I just created |
|
I slept on it and now think that |
|
Agree. I also wonder whether all callsites of |
|
Here is a proof-of-concept change for |
Sounds reasonable. |
PHPUnit uses
SebastianBergmann\Exporter\Exporterfromsebastian/exporterto export variables as strings, for instance when generating comparison failure messages or when creating immutable value objects representing tests and their data (from data providers) that are passed through the event system to internal as well as third-party subscribers.In order to allow for the customization of the textual representation of comparison failures, to improve performance (using
SebastianBergmann\Exporter\Exporteris expensive when large data structures are involved), and for other use cases it would be nice ifSebastianBergmann\Exporter\Exportercould be swapped for a different implementation.PHPUnit\Util\ExporterinterfacePHPUnit\Util\DefaultExporteras the default implementation ofPHPUnit\Util\Exporterthat simply wrapsSebastianBergmann\Exporter\ExporterPHPUnit\Util\ExporterFacadethat usesPHPUnit\Util\DefaultExporterby default, but can be configured to use an alternative implementation ofPHPUnit\Util\ExporterPHPUnit\Util\ExporterChainfor chainingPHPUnit\Util\ExporterimplementationsExporterFacade::instance()->export()instead ofSebastianBergmann\Exporter\Exporter::export()PHPUnit\Util\Exporterconfigurable via PHPUnit's XML configuration fileSebastianBergmann\Exporter\Exporter::shortenedRecursiveExport()andSebastianBergmann\Exporter\Exporter::shortenedExportshould also be wrappedSebastianBergmann\Exporter\Exporterinsebastian/comparatorshould also be configurable