0
votes

I'm trying to do unit tests with laravel but get the following error. I've not got to testing the function. In my editor, I see the reference to the class correctly, however phpunit can't find it.

 Error: Class 'GoCardlessCheck' not found

my test looks like this

  use Illuminate\Foundation\Testing\WithoutMiddleware;
  use Illuminate\Foundation\Testing\DatabaseMigrations;
  use Illuminate\Foundation\Testing\DatabaseTransactions;
  use PHPUnit\Framework\TestCase;



class GoCardlessTest extends TestCase
{
/**
 * A basic test example.
 *
 * @return void
 */
 public function testExample()
 {
    $acc = new GoCardlessCheck();

    $acc->CheckAccount('bob','mould','909090','57-77-90');

 }

}

1
Have imported the class GoCardlessCheck ? - Prince Lionel N'zi
imported the class? what do you mean? - GAV

1 Answers

0
votes

I had the same issue randomly occur for me, and this is what fixed it.

First, ensure that you're including a use path\to\GoCardlessCheck statement. If that path is in the tests namespace, make sure that you have

"autoload-dev": {
    "classmap": [
        "tests/"
    ]
}

in your composer.json file.

If all that is there, try running composer update.

After doing this the error went away, and my tests ran properly again.