chrismay
1 week ago

aspectmock Class Eloquent was not found by locator

Posted 1 week ago by chrismay

I have installed aspectmock and codeception, but I get InvalidArgumentException : Class Eloquent was not found by locator when I try to use it in my tests.

My tests/bootstrap.php:

require_once  __DIR__.'/../bootstrap/app.php';
require_once  __DIR__.'/../vendor/autoload.php';

$kernel = \AspectMock\Kernel::getInstance();

$kernel->init([
    'debug' => true,
    'cacheDir' => __DIR__ . '/_tmp/aspectMock/cache',
    'includePaths' => [
        __DIR__ . '/../vendor/laravel',
        __DIR__ . '/../app'
    ],
    'excludePaths' => [
        __DIR__,
    ]
]);

$kernel->loadFile(__DIR__.'/../bootstrap/app.php');
$kernel->loadFile(__DIR__.'/../vendor/autoload.php');

Is the bootstrap code wrong?

codeception.yml

paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
bootstrap: bootstrap.php
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed

coverage:
    enabled: true
    include:
        - app/*

Please sign in or create an account to participate in this conversation.