2

Could anyone help me understand the reasons that why these unit tests are failing at CI while they pass on local setup.

The repository is at https://github.com/jabranr/test-ci

The tests are at https://travis-ci.org/jabranr/test-ci

The tests fail in CI with a fatal error saying: PHP Fatal error: Class 'JRI\JabranCI\Exception\FooBarException' not found in /home/travis/build/jabranr/test-ci/test/exception/FooBarExceptionTest.php on line 11

The package uses the PSR-4 autoloading. Here is the composer.json and phpunit configuration. Thank you in advance!

1 Answer 1

5

So I figured that these tests are failing because names of directories do not match the PSR-4 autoload case sensitive scheme.

In this particular case, this was directly related to case insensitive nature of OSX. While the unit tests worked fine and passed on an OSX local machine, they kept failing on Travis CI as it bases the tests on Linux (Ubuntu) containers.

So basically from above example, when calling JRI\JabranCI\Exception\FooBarException, directory structure should be src/JRI/JabranCI/Exception/FooBarException.php

Generic example:

If there is a class Baz with namespace Foo\Bar then using PSR-4 a valid directory structure is src/Foo/Bar/Baz.php. The directory structure of src/foo/bar/Baz.php is invalid in such a case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.