EcomDev_PHPUnit icon indicating copy to clipboard operation
EcomDev_PHPUnit copied to clipboard

Duplication of class Spyc

Open barbazul opened this issue 7 years ago • 0 comments

We are currently using Composer to deploy Magento with its modules and also some other non-Magento related tools used for our CI cycle.

We are currently using the dev branch of EcomDev_PHPUnit

We recently run into an issue where PHPUnit crashed silently and it took us several hours before we found out that the source of the problem was that Spyc was being autoloaded via composer at the beginning of the PHPUnit process and later again when loading tests that use either a fixture or dataProvider (we are not using expectations, but I assume its the same case).

The problem was that the first line of EcomDev_PHPUnit_Model_Yaml_Loader does a require_once 'Spyc/spyc.php' without considering the possibility of it already beind loaded gloabally.

For our case, simply wrapping the require_once in if (!class_exists('Spyc', false)) fixed the issue.

Looking closely at the 2 versions of Spyc, we noticed the one we have via Composer is version 0.6.2 while the one bundled with EcomDev_PHPUnit is version 0.4.5 so I am not 100% this fix will work in every scenario.

I can provide a PR with this fix unless the Spyc version needs to be fixed to 0.4.5 for some reason.

Comparing both versions, I only noticed differences in comments, internal functions naming, a bunch of dump stuff (not used by this module) and some additional controls when loading files. Nothing struck me as a possible compatibility breaker but I am not that familiar with Spyc.

barbazul avatar Jun 17 '17 16:06 barbazul