6
votes

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"
    }
},
1
People might have more ideas if you show the actual code you're running.jessica
@jessica I added the header of the file from where the error originates. Can you think of anything else that would be useful? I don't the think the actual unit tests are relevant because the problem isn't an assertion failing, rather the actual code erroring.emersonthis

1 Answers

2
votes

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.