{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/12419","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/12419/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/12419/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/12419/events","html_url":"https://github.com/magento/magento2/issues/12419","id":276433873,"number":12419,"title":"Fails and warnings while running unit tests","user":{"login":"bnymn","id":3506402,"avatar_url":"https://avatars2.githubusercontent.com/u/3506402?v=4","gravatar_id":"","url":"https://api.github.com/users/bnymn","html_url":"https://github.com/bnymn","followers_url":"https://api.github.com/users/bnymn/followers","following_url":"https://api.github.com/users/bnymn/following{/other_user}","gists_url":"https://api.github.com/users/bnymn/gists{/gist_id}","starred_url":"https://api.github.com/users/bnymn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnymn/subscriptions","organizations_url":"https://api.github.com/users/bnymn/orgs","repos_url":"https://api.github.com/users/bnymn/repos","events_url":"https://api.github.com/users/bnymn/events{/privacy}","received_events_url":"https://api.github.com/users/bnymn/received_events","type":"User","site_admin":false},"labels":[{"id":688811200,"url":"https://api.github.com/repos/magento/magento2/labels/G1%20Passed","name":"G1 Passed","color":"0e8a16","default":false},{"id":686420665,"url":"https://api.github.com/repos/magento/magento2/labels/G2%20Passed","name":"G2 Passed","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-23T16:47:51Z","updated_at":"2017-11-25T12:30:14Z","closed_at":null,"author_association":"NONE","body":"After fresh installation of Magento 2.2 via composer, some of the unit tests are failing.\r\n\r\n### Preconditions\r\n1. Magento 2.2\r\n2. PHP 7.0\r\n3. MySQL 5.7.19, for Linux (x86_64)\r\n\r\n### Steps to reproduce\r\n1. Install Magento with **composer**.\r\n2. Run this command `vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist`.\r\n3. You get the error.\r\n\r\n### Expected result\r\n1. To pass all the unit tests\r\n\r\n### Actual result\r\n1. There are some PHP Warnings as following\r\n```\r\nPHP Warning:  Invalid argument supplied for foreach() in /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php on line 707\r\nPHP Stack trace:\r\nPHP   1. {main}() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:0\r\nPHP   2. PHPUnit\\TextUI\\Command::main() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:53\r\nPHP   3. PHPUnit\\TextUI\\Command->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:141\r\nPHP   4. PHPUnit\\TextUI\\TestRunner->doRun() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:212\r\nPHP   5. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:537\r\nPHP   6. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\nPHP   7. PHPUnit\\Framework\\TestCase->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\nPHP   8. PHPUnit\\Framework\\TestResult->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:883\r\nPHP   9. PHPUnit\\Framework\\TestCase->runBare() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestResult.php:695\r\nPHP  10. PHPUnit\\Framework\\TestCase->runTest() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:928\r\nPHP  11. ReflectionMethod->invokeArgs() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\nPHP  12. Magento\\Dhl\\Test\\Unit\\Model\\CarrierTest->testCollectRatesFail() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\nPHP  13. Magento\\Dhl\\Model\\Carrier->collectRates() /var/www/magento2.2/vendor/magento/module-dhl/Test/Unit/Model/CarrierTest.php:370\r\nPHP  14. Magento\\Dhl\\Model\\Carrier->_getQuotes() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:351\r\nPHP  15. Magento\\Dhl\\Model\\Carrier->_buildQuotesRequestXml() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:928\r\nPHP  16. Magento\\Dhl\\Model\\Carrier->_makePieces() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:1015\r\nPHP  17. Magento\\Dhl\\Model\\Carrier->_getAllItems() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:797\r\n.\r\nWarning: Invalid argument supplied for foreach() in /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php on line 707\r\n\r\nCall Stack:\r\n    0.0002     365240   1. {main}() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:0\r\n    0.0089    1313352   2. PHPUnit\\TextUI\\Command::main() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:53\r\n    0.0089    1313464   3. PHPUnit\\TextUI\\Command->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:141\r\n    8.6191  314715520   4. PHPUnit\\TextUI\\TestRunner->doRun() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:212\r\n    8.6299  314876768   5. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:537\r\n   33.9640  641796024   6. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\n   34.0214  643598816   7. PHPUnit\\Framework\\TestCase->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\n   34.0214  643598816   8. PHPUnit\\Framework\\TestResult->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:883\r\n   34.0215  643601792   9. PHPUnit\\Framework\\TestCase->runBare() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestResult.php:695\r\n   34.0229  643689440  10. PHPUnit\\Framework\\TestCase->runTest() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:928\r\n   34.0229  643689736  11. ReflectionMethod->invokeArgs() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\n   34.0229  643689744  12. Magento\\Dhl\\Test\\Unit\\Model\\CarrierTest->testCollectRatesFail() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\n   34.0230  643690728  13. Magento\\Dhl\\Model\\Carrier->collectRates() /var/www/magento2.2/vendor/magento/module-dhl/Test/Unit/Model/CarrierTest.php:370\r\n   34.0252  643706280  14. Magento\\Dhl\\Model\\Carrier->_getQuotes() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:351\r\n   34.0252  643706336  15. Magento\\Dhl\\Model\\Carrier->_buildQuotesRequestXml() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:928\r\n   34.0264  643714416  16. Magento\\Dhl\\Model\\Carrier->_makePieces() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:1015\r\n   34.0265  643715208  17. Magento\\Dhl\\Model\\Carrier->_getAllItems() /var/www/magento2.2/vendor/magento/module-dhl/Model/Carrier.php:797\r\n```\r\n\r\n2. The second PHP warning\r\n```\r\nPHP Warning:  filesize(): stat failed for /t/e/test.jpg in /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php on line 181\r\nPHP Stack trace:\r\nPHP   1. {main}() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:0\r\nPHP   2. PHPUnit\\TextUI\\Command::main() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:53\r\nPHP   3. PHPUnit\\TextUI\\Command->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:141\r\nPHP   4. PHPUnit\\TextUI\\TestRunner->doRun() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:212\r\nPHP   5. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:537\r\nPHP   6. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\nPHP   7. PHPUnit\\Framework\\TestCase->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\nPHP   8. PHPUnit\\Framework\\TestResult->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:883\r\nPHP   9. PHPUnit\\Framework\\TestCase->runBare() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestResult.php:695\r\nPHP  10. PHPUnit\\Framework\\TestCase->runTest() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:928\r\nPHP  11. ReflectionMethod->invokeArgs() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\nPHP  12. Magento\\ProductVideo\\Test\\Unit\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImageTest->testExecute() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\nPHP  13. Magento\\ProductVideo\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImage->execute() /var/www/magento2.2/vendor/magento/module-product-video/Test/Unit/Controller/Adminhtml/Product/Gallery/RetrieveImageTest.php:152\r\nPHP  14. Magento\\ProductVideo\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImage->appendResultSaveRemoteImage() /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php:120\r\nPHP  15. filesize() /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php:181\r\nF\r\nWarning: filesize(): stat failed for /t/e/test.jpg in /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php on line 181\r\n\r\nCall Stack:\r\n    0.0002     365240   1. {main}() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:0\r\n    0.0089    1313352   2. PHPUnit\\TextUI\\Command::main() /var/www/magento2.2/vendor/phpunit/phpunit/phpunit:53\r\n    0.0089    1313464   3. PHPUnit\\TextUI\\Command->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:141\r\n    8.6191  314715520   4. PHPUnit\\TextUI\\TestRunner->doRun() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/Command.php:212\r\n    8.6299  314876768   5. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:537\r\n   42.2900  752315928   6. PHPUnit\\Framework\\TestSuite->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\n   42.2916  752316552   7. PHPUnit\\Framework\\TestCase->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestSuite.php:744\r\n   42.2916  752316552   8. PHPUnit\\Framework\\TestResult->run() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:883\r\n   42.2917  752319528   9. PHPUnit\\Framework\\TestCase->runBare() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestResult.php:695\r\n   42.3047  752789864  10. PHPUnit\\Framework\\TestCase->runTest() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:928\r\n   42.3047  752790160  11. ReflectionMethod->invokeArgs() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\n   42.3047  752790168  12. Magento\\ProductVideo\\Test\\Unit\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImageTest->testExecute() /var/www/magento2.2/vendor/phpunit/phpunit/src/Framework/TestCase.php:1069\r\n   42.3049  752797632  13. Magento\\ProductVideo\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImage->execute() /var/www/magento2.2/vendor/magento/module-product-video/Test/Unit/Controller/Adminhtml/Product/Gallery/RetrieveImageTest.php:152\r\n   42.3056  752804240  14. Magento\\ProductVideo\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImage->appendResultSaveRemoteImage() /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php:120\r\n   42.3058  752806392  15. filesize() /var/www/magento2.2/vendor/magento/module-product-video/Controller/Adminhtml/Product/Gallery/RetrieveImage.php:181\r\n```\r\n\r\n3. Failed test\r\n```\r\nThere was 1 failure:\r\n\r\n1) Magento\\ProductVideo\\Test\\Unit\\Controller\\Adminhtml\\Product\\Gallery\\RetrieveImageTest::testExecute\r\nExpectation failed for method name is equal to <string:getDirectoryWrite> when invoked 1 time(s).\r\nMethod was expected to be called 1 times, actually called 0 times.\r\n```"},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/346937754","html_url":"https://github.com/magento/magento2/issues/12419#issuecomment-346937754","issue_url":"https://api.github.com/repos/magento/magento2/issues/12419","id":346937754,"user":{"login":"barbazul","id":240373,"avatar_url":"https://avatars3.githubusercontent.com/u/240373?v=4","gravatar_id":"","url":"https://api.github.com/users/barbazul","html_url":"https://github.com/barbazul","followers_url":"https://api.github.com/users/barbazul/followers","following_url":"https://api.github.com/users/barbazul/following{/other_user}","gists_url":"https://api.github.com/users/barbazul/gists{/gist_id}","starred_url":"https://api.github.com/users/barbazul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/barbazul/subscriptions","organizations_url":"https://api.github.com/users/barbazul/orgs","repos_url":"https://api.github.com/users/barbazul/repos","events_url":"https://api.github.com/users/barbazul/events{/privacy}","received_events_url":"https://api.github.com/users/barbazul/received_events","type":"User","site_admin":false},"created_at":"2017-11-25T12:30:14Z","updated_at":"2017-11-25T12:30:14Z","author_association":"CONTRIBUTOR","body":"I haven't dug too deep into the code but it looks like when the filesystem mock is set up, `getDirectoryWrite` is expected to by called once https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/ProductVideo/Test/Unit/Controller/Adminhtml/Product/Gallery/RetrieveImageTest.php#L149\r\n\r\nHowever, that method is only called if there is an exception: https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php#L123\r\n\r\nNone of the mocks being set up is told to throw an exception (unlike the `testExecuteInvalid...` tests).\r\n\r\nSo it looks like the failure itself is being caused by wrongly setting up the mock to expect a call to `getDirectoryWrite()`\r\n\r\nI am really surprised this error does not show up in Travis https://travis-ci.org/magento/magento2/jobs/307118009 "}}
{"actor":{"display_login":"barbazul"}}