Codeception/AspectMock

Cant mock laravel Model

lotarbo opened this issue · 2 comments

Hi, i use
"codeception/aspect-mock": "^3.0"
"laravel/framework": "5.6."
php 7.1.

Try to do in test
MyModel.php

class MyModel extends Model
{
.....
public function someTest()
{
  return 'old return';
}
.....
}
use AspectMock\Test as test;
......
test::double(MyModel::class, [
            'someTest' => 'new return',
        ]);
$m = new MyModel();
var_dump($m->someTest());
......

i see 'old return', not what i exept;

config file

require __DIR__ . '/autoload.php';
        $kernel = \AspectMock\Kernel::getInstance();
        $kernel->init([
            'debug' => true,
            'cacheDir' => app_path() . '/../storage/framework/cache/data',
            'includePaths' => [
                app_path(),
                app_path() . '/../vendor/laravel',
            ],
            'excludePaths' => [
                app_path() . '/../test',
            ]
        ]);

Same here, desperatly trying to get AspeckMock running, but the setup it quite horrible :/
@lotarbo what do you mean with "config file" ?

@panique only showing my environment, mb i missing something in setup)