vendredi 4 juin 2021

How to make Mockery overload option work properly on Laravel 5

I'm trying to use overload option of Mockery library on Laravel 5.

I write this test case:

<?php

namespace Tests\Unit;

use Mockery;
use Tests\TestCase;

/**
 * @runTestsInSeparateProcesses
 * @preserveGlobalState disabled
 */
class RenewSignatureTest extends TestCase
{
    public function testHandle()
    {
        /** @var mixed $mock */
        $mock = Mockery::mock('overload:App\FooClass');
        $mock->shouldReceive('callBar')->times(2);
    }
}

According to documentation, this test should fail, but, does not matter what I do, the test never fails! It always result in:

Time: 304 ms, Memory: 19.53 MB

OK (1 test, 1 assertion)

If I remove the 'overload:' option (code bellow), the test fails. So I assume that I'm not using library methods on the wrong way.

<?php

namespace Tests\Unit;

use Mockery;
use Tests\TestCase;

/**
 * @runTestsInSeparateProcesses
 * @preserveGlobalState disabled
 */
class RenewSignatureTest extends TestCase
{
    public function testHandle()
    {
        /** @var mixed $mock */
        $mock = Mockery::mock('overload:App\FooClass');
        $mock->shouldReceive('callBar')->times(2);
    }
}

Am I doing anything wrong? Does anyone know how to use this option properly?

My current environment:

  • Laravel 5
  • Mockery 1.0
  • PHPUnit 7.5


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3cfjFYA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire