Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Cache Facade #357

Open
nickpoulos opened this issue Nov 2, 2021 · 0 comments
Open

Testing Cache Facade #357

nickpoulos opened this issue Nov 2, 2021 · 0 comments

Comments

@nickpoulos
Copy link

Not sure if this is a PEST or Laravel Zero issue, or just me...prob the latter.

But I am trying to test a class that has another class as a dependency, and this dependency uses the Cache Facade.

In regular Laravel/PHPUnit, I am able to use the Cache::shouldReceive() and other helper methods to mock facades.

When trying this in my current Laravel Zero/Pest project, I am getting:

Illuminate\Contracts\Container\BindingResolutionException

Target class [cache] does not exist.

My test

test('Vault Retriever ', function (string $annotationData, bool $expectedResult) {
    Cache::shouldReceive('get')->once();
    $vaultRetriever= app()->make(VaultRetriever::class);
    $result = $vaultRetriever->filter($annotationData);
    expect($result)->toBe($expectedResult);
})->with([
   ['vault:secret/data/test/some/stupid#path', true],
   ['vault:missing/stuff', false],
]);

Any idea what the issue is here? Or what I can do to correct?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant