'Why is Laravel facade spy not working in certain test cases (Laravel testing)
I am studying Laravel's facade spies, but I can't understand why the first test below works and the second doesn't.
<?php
namespace Tests\Unit\Helpers;
use Tests\TestCase;
use Illuminate\Support\Facades\Cookie;
class MyTest extends TestCase
{
/** @test */
public function it_sets_a_cookie()
{
Cookie::spy();
Cookie::queue('name', 'value', minutes: 100);
Cookie::shouldHaveReceived('queue'); // This works
}
/** @test */
public function it_reads_a_cookie()
{
Cookie::spy();
Cookie::get('name');
Cookie::shouldHaveReceived('get'); // This fails
}
}
Laravel documentation reference
I'm using Laravel 9.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
