|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Customer\Test\Unit\Model\App\FrontController; |
| 9 | + |
| 10 | +use Magento\Customer\Model\App\FrontController\DeleteCookieWhenCustomerNotExistPlugin; |
| 11 | +use Magento\Framework\App\Response\Http as ResponseHttp; |
| 12 | +use Magento\Customer\Model\Session; |
| 13 | +use PHPUnit\Framework\MockObject\MockObject; |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | + |
| 16 | +/** |
| 17 | + * Tests \Magento\Customer\Model\App\FrontController\DeleteCookieWhenCustomerNotExistPluginTest. |
| 18 | + */ |
| 19 | +class DeleteCookieWhenCustomerNotExistPluginTest extends TestCase |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @var DeleteCookieWhenCustomerNotExistPlugin |
| 23 | + */ |
| 24 | + protected DeleteCookieWhenCustomerNotExistPlugin $plugin; |
| 25 | + |
| 26 | + /** |
| 27 | + * @var ResponseHttp|MockObject |
| 28 | + */ |
| 29 | + protected ResponseHttp|MockObject $responseHttpMock; |
| 30 | + |
| 31 | + /** |
| 32 | + * @var Session|MockObject |
| 33 | + */ |
| 34 | + protected MockObject|Session $customerSessionMock; |
| 35 | + |
| 36 | + /** |
| 37 | + * Set up |
| 38 | + */ |
| 39 | + protected function setUp(): void |
| 40 | + { |
| 41 | + $this->customerSessionMock = $this->createMock(Session::class); |
| 42 | + $this->responseHttpMock = $this->createMock(ResponseHttp::class); |
| 43 | + $this->plugin = new DeleteCookieWhenCustomerNotExistPlugin( |
| 44 | + $this->responseHttpMock, |
| 45 | + $this->customerSessionMock |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + public function testBeforeDispatch() |
| 50 | + { |
| 51 | + $this->customerSessionMock->expects($this->once()) |
| 52 | + ->method('getCustomerId') |
| 53 | + ->willReturn(0); |
| 54 | + $this->plugin->beforeDispatch(); |
| 55 | + } |
| 56 | +} |
0 commit comments