AspectMock icon indicating copy to clipboard operation
AspectMock copied to clipboard

Cant mock laravel Model

Open lotarbo opened this issue 5 years ago • 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',
            ]
        ]);

lotarbo avatar Oct 23 '18 11:10 lotarbo

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

panique avatar May 07 '20 16:05 panique

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

lotarbo avatar Jun 19 '20 11:06 lotarbo