ldc-cocotte/tests/Feature/App/Http/Controllers/Fo/NewsletterControllerTest.php
Jérémy Munsch 8b96ce90be
test(casts): add tests for EmployeeSitesCast functionality
test(casts): add tests for ShopperEstablishmentCodeCast functionality

test(casts): add tests for ShopperServiceCodeCast functionality

test(casts): add tests for ShopperSiteCodeCast functionality

test(dto): update ProductDtoTest to include additional fields

test(dto): update SettingDtoTest to remove arcadiaSites assertions

test(events): update AnOrderHasBeenPlacedTest to use value objects

test(entities): update OrderTest to use value objects for employee details

test(value-objects): update EmployeeUpsertDataTest to use value objects

test(pagination): update PaginationTest to access value properties

test(services): update AppCustomerAuthServiceTest to use CrmHashcode

test(services): update CrmServiceTest to use CrmHashcode for customer retrieval
2026-10-27 09:58:45 +01:00

49 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\Page;
use App\Services\CrmService;
use Database\Seeders\ContentSeeder;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\View;
use Ramsey\Uuid\Uuid;
describe('NewsletterController', function () {
it('can access get /unsubscribe with valid hashcode', function () {
// GIVEN
/** @var \Tests\TestCase $this */
$crmMock = $this->mock(CrmService::class);
$crmMock->shouldReceive('unsubscribeCustomer')->andReturn(true);
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
$hashcode = Uuid::uuid4()->toString();
// WHEN
$response = $this->get('/unsubscribe?hashcode=' . $hashcode);
// THEN
$response->assertStatus(200);
});
it('redirects when hashcode is missing', function () {
// GIVEN
/** @var \Tests\TestCase $this */
$this->seed(ContentSeeder::class);
View::share('PageList', Page::getCached()
->mapWithKeys(fn ($page) => [
$page->slug->value() => $page,
]));
Cache::flush();
// WHEN
$response = $this->get('/unsubscribe');
// THEN
$response->assertStatus(302);
});
});