Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP class not found error ONLY happens on CircleCI

I'm not seeing any errors when I run or test my code locally. My phpunit test suite passes:

Time: 11.69 seconds, Memory: 43.50Mb

OK, but incomplete, skipped, or risky tests!
Tests: 149, Assertions: 281, Incomplete: 13.

But when I push the exact same code and CircleCI runs the exact same test command, it fails with a fatal error:

.PHP Fatal error: Class 'App\Domain\API\Request\Soap\Json\AbstractJson' not found in /home/ubuntu/TransitScreen/src/Domain/Api/Request/Soap/Json/NJTransit.php on line 10 php ./vendor/bin/phpunit --no-coverage --testsuite=unit returned exit code 255

Here's my circle.yml:

test:
  override:
    - php ./vendor/bin/phpunit --no-coverage --testsuite=unit

machine:
  php:
    version: 5.6.5
  environment:
    APP_ENV: circleci

The file it's referencing begins with:

<?php

namespace App\Domain\API\Request\Soap\Json;

use App\Domain\Api\Request\InputApiDataRequest;
use App\Domain\Api\Request\Soap\AsyncSoapClient;
use Assert\Assertion;

class NJTransit extends AbstractJson
{

At first I thought maybe CircleCi was running an old version of PHP without namespaces or something but even when I set it to use PHP v5.6.5 the same error happens. I even tried adding a database dump into the test sequence.

It's even stranger to me that it is able to run several dozen tests before the error happens. So I'm pretty sure that it's not something grossly misconfigured on CircleCI.

Any suggestions on why the same code would behave so differently in the two environments?

UPDATE 1: I found this question which sounds very similar but so far overriding the composer command hasn't resolved by issue. Laravel - CircleCI - Fails on phpunit

UPDATE 2: I found this question which talks about autoloaging not working... It suggests a new theory... perhaps there is a problem involving case sensitivity differences between OSX (my local environment) and Ubuntu (CircleCI). Here is the relevant segment of my composer.json file:

"autoload": {
    "psr-4": {
        "App\\": "src"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Test\\": "tests",
        "Cake\\Test\\": "./vendor/cakephp/cakephp/tests",
        "TestApp\\": "tests/TestApp/src",
        "TestApp\\Test\\": "tests/TestApp/tests"
    }
},
like image 328
emersonthis Avatar asked Oct 06 '15 21:10

emersonthis


1 Answers

Took me a while to spot it even with the code example you've given, but it looks like part of the namespace is the wrong case (API vs Api)?

Contrary to popular belief, OS X machines come formatted case-insensitive by default which unfortunately makes them more like Windows machines in this regard.

like image 144
deizel Avatar answered Nov 06 '22 07:11

deizel