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

[5.7] causes problem when we write unit-test in `cache('foo')` #25492

Merged
merged 1 commit into from Sep 7, 2018

Conversation

Projects
None yet
2 participants
@klack710
Contributor

klack710 commented Sep 6, 2018

https://laravel.com/docs/5.7/facades#facades-vs-helper-functions

There is absolutely no practical difference between facades and helper functions. When using helper functions, you may still test them exactly as you would the corresponding facade.

The above statement is incorrect in regards to cache('foo')

public function testBasicExample()
{
    Cache::shouldReceive('get')
         ->with('key')
         ->andReturn('value');

    $this->visit('/cache')
         ->see('value');
}

This sample code can’t work because cache method changes parameters.

When we call cache('foo'), this method call Cache::get('foo', null). So it causes problem when we write unit-test.

@GrahamCampbell GrahamCampbell changed the title from causes problem when we write unit-test in `cache('foo')` to [5.7] causes problem when we write unit-test in `cache('foo')` Sep 6, 2018

@taylorotwell taylorotwell merged commit 757d3c7 into laravel:5.7 Sep 7, 2018

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment