-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in PHPUnit test (null should be array) #3533
Comments
What's the status on this @okorshenko? |
Dug into this yesterday, and interestingly this is caused with PHP 7 by a state leakage via public function __construct(
\Magento\Setup\Module\Di\Compiler\Log\Log $log,
\Magento\Framework\Code\Reader\ClassReader $classReader,
\Magento\Setup\Module\Di\Code\Reader\ClassesScanner $classesScanner,
\Magento\Framework\Code\Validator $validator,
$generationDir
) {
$this->log = $log;
$this->classReader = $classReader;
$this->classesScanner = $classesScanner;
$this->validator = $validator;
$this->generationDir = $generationDir;
set_error_handler([$this, 'errorHandler'], E_STRICT);
} Under PHP 5.6 this does not cause problems, only with PHP 7. Minimum steps to reproduce:
<testsuite name="Debug Unit Tests">
<file>../../../setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/InstancesNamesList/DirectoryTest.php</file>
<file>../../../vendor/magento/module-downloadable-import-export/Test/Unit/Model/Import/Product/Type/DownloadableTest.php</file>
</testsuite>
Possible Solution A reliable fix is to restore the previous error handler in a protected function tearDown()
{
restore_error_handler();
} I've tried to use the |
It's not only PHP 7 problem. I've had the same with PHP 5.6.17 (but with Zend Opcache v7.0.6-dev). "tearDown" is good solution, thanks. |
Thank you for your submission. We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues. Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here). We are closing this GitHub ticket and have moved your request to the new forum. |
[TSG] MFTF for 2.2 (pr10) (2.2.8)
Hello all,
I just launched the standard PHPUnit test (without the dev:tests:run command) :
php <magentodir>/vendor/phpunit/phpunit/phpunit --debug
I am in
<magentodir>/dev/tests/unit
directory.There is a fatal error on
Magento\DownloadableImportExport\Model\Import\Product\Type\Downloadable
file. On functionfillDataLink
, there is afillExistOptions
call where$existingOptions
is null. It should be an array. It's the same infillDataTitleLink
method.I just add an ugly fix with a
is_null
check for$existingOptions
and set it to an empty array and it works.I think the best way should be to change the
fetchAll
method to always return an empty array, if no data is retrieved in database.Is there something I did wrong ?
Damien.
The text was updated successfully, but these errors were encountered: