vendredi 17 mai 2019

How to fix "Can't close mock after test completed, it visible in another tests"

I created simple mock. But it visible during all test execution. Tried tearDown in laravel and Mockery::close but it didn't help. Thanks for any help

Looked for information about this problem but found nothing.

    $mock = Mockery::mock("App\Repository\MainCity\Interfaces\GetMainCitiesInterface");
    $mock->shouldReceive('getMainCities')->once()->with("ru")->andreturn($return);
    app()->instance("App\Repository\MainCity\Interfaces\GetMainCitiesInterface", $mock);

    $gmcci = app()->make("App\Repository\MainCity\Caching\Interfaces\GetMainCitiesCacheInterface");
    $gmci = app()->make("App\Repository\MainCity\Interfaces\GetMainCitiesInterface");

    $res = $gmcci->getMainCitiesCache(
                            "ru",
                            $gmci
                            );

    $this->assertTrue( $res == $return );   

    \Mockery::close();

I expect to get real cities in some requests but get mocked result

Aucun commentaire:

Enregistrer un commentaire