1
votes

My project runs just fine using PHP 5.6, 7.0, 7.1 (I haven't tried running it using nightly or HHVM), it's just my tests that all fail when using PHP 7.1, nightly, and HHVM. My tests run successfully using PHP 5.6 and 7.0. They were working fine, until I switched to using Composer for one of my components and it caused my directory structure to be adjusted a bit. But given that it works just fine in some PHP versions, and not others, I don't think I have a simple "typo" per se. Is this a potential issue with PHP 7.1? I looked at change logs between PHP 7.0 and 7.1 to see if something stood out about how namespaces or autoloading, but I didn't see anything.

I'm using Travis CI to build my project and run my tests. The results I'm trying to debug can be found here: https://travis-ci.org/dbudwin/RoboHome-Web/jobs/173488168

They all result in the same error of not being able to find classes, for instance:

1) Tests\Models\DevicesModelTest::testAdd
Error: Class 'Models\DevicesModel' not found

Here is a direct link to my pull request that needs work: https://github.com/dbudwin/RoboHome-Web/pull/45

1
Same problem with PHP 7.0.9 with Xdebug v2.4.0. No problem on the master branch with same configuration.Matteo

1 Answers

1
votes

In the composer.json on the branch F3Composer you missing to update the psr-4 of the autoload section. You refactor the path of the class but don't update the autoload. so change your autoload as follow:

composer.json

"autoload": {
    "psr-4": {
        "Models\\":"app/models",
        "Controllers\\":"app/controllers"
    }
},

rerun the composer install (that regenerate the autoloader files) and the test suite will go green.

Hope this help