Skip to content
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

Unit test fails after fresh installation #11230

Closed
bnymn opened this issue Oct 4, 2017 · 7 comments
Closed

Unit test fails after fresh installation #11230

bnymn opened this issue Oct 4, 2017 · 7 comments
Assignees
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@bnymn
Copy link
Contributor

bnymn commented Oct 4, 2017

I have freshly installed Magento 2.2. The first thing I do is running unit tests. I have got one error.

Preconditions

  1. Magento 2.2
  2. PHP 7.0
  3. MySQL 5.7.19, for Linux (x86_64)

Steps to reproduce

  1. Install Magento with composer
  2. Run this command vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist
  3. You get the error

Expected result

  1. To pass all the unit tests

Actual result

  1. You got the following error:
Magento\Setup\Test\Unit\Module\Di\Code\Reader\FileClassScannerTest::testClassKeywordInMiddleOfFile
Magento\Setup\Module\Di\Code\Reader\InvalidFileException: The file "/var/www/html/magento2-install1" does not exist or is not a file

/var/www/html/magento2-install1/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php:39
/var/www/html/magento2-install1/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/FileClassScannerTest.php:213

When I look at this file setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/FileClassScannerTest.php, I am seeing the following test.

public function testClassKeywordInMiddleOfFile()
{
    $filename = __DIR__
        . '/../../../../../../../../../..'
        . '/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php';
    $filename = realpath($filename);
    $scanner = new FileClassScanner($filename);
    $result = $scanner->getClassNames();

    self::assertCount(1, $result);
}

This is interesting that there is not any file in app/code, since the file it is looking for inside vendor directory.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Oct 4, 2017
@magento-engcom-team magento-engcom-team self-assigned this Oct 5, 2017
@magento-engcom-team
Copy link
Contributor

@bnymn, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.2.0

@magento-engcom-team magento-engcom-team added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Oct 5, 2017
@ghost
Copy link

ghost commented Oct 19, 2017

This can be reproduced by installing Magento 2.2 via composer.

The test will look for:
app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php

It won't find the file, because it is located at:
vendor/magento/module-catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php

@peterjaap
Copy link
Contributor

Confirmed what @vanpoppel says. Please reopen issue @magento-engcom-team

@ghost
Copy link

ghost commented Oct 23, 2017

I would like to know if this test is intended for use on a Magento2 installed via composer. When you install Magento2 by creating a clone from the Magento2 repository you won't have this problem. But (I hope) people only do this to contribute to Magento2.

Is a developer supposed to be able to run all unit tests when installed via composer? Or only the ones they write themselves?

@bnymn
Copy link
Contributor Author

bnymn commented Oct 23, 2017

@vanpoppel I think that a developer must have the ability to run all unit tests, because sometimes we are writing plugins which changes the behavior of core modules. In this case, we need to make sure that everything is working just fine.

@magento-team
Copy link
Contributor

Hi @bnymn. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1287 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming patch release.

@magento-team magento-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Jan 25, 2018
@giuseppemorelli
Copy link
Member

As #12419 if you want to avoid the problem (but not fix the error)

In /dev/tests/unit/phpunit.xml.dist exlude FileClassScannerTest.phptest

<testsuite name="Magento Unit Tests">
       .....

<exclude>../../../setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Reader/FileClassScannerTest.php</exclude>
    </testsuite>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

5 participants