experius / Magento-2-Module-Experius-Postcode-NL

PostcodeNl Api Magento 2 Module. Available At Packagist
https://packagist.org/search/?q=experius
Open Software License 3.0
29 stars 31 forks source link

Rename console command Test to LookupTest #70

Open peterjaap opened 2 years ago

peterjaap commented 2 years ago

In our pipeline, we ran into this error;

PHP Fatal error:  Uncaught Error: Class "Experius\Postcode\Console\Command\Test\Interceptor" not found in /data/web/releases/20220929141143/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:121

For extra security, we run composer dump --classmap-authoritative in our pipeline, creating a classmap for all classes in the project. However, Magento by default excludes Tests from the classmap, see here.

This usually isn't a problem since Tests shouldn't be referenced by production code anyway. However in this case, Composer thinks the console command named "Test" is in fact a test, and skips this class when creating the classmap, causing the Uncaught Error Class not found to occur.

Simply renaming Test to something else fixes this. I've named it LookupTest here, since that is what it does. I've kept the command itself (bin/magento experius_postcode:test) the same for backwards compatibility.

peterjaap commented 2 years ago

@Hexmage @lewisvoncken ?