DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

Why Mockerty is unable to make an alias of my model

Hello how I can mock a static method of an Eloquent Model?
I tried the following without any hope.

I have the following model:

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
    public static function foo():bool
    {
      return true;
    }
}

And for that I made the following controller:


namespace App\Controler;

use App\Model\Foo;

class MyController
{
   public function bar()
   {
      $value=MyModel::foo();
      if($value){
        return "OK"; 
      }
      throw new \Exception("Foo

Any ideas?

Top comments (0)