![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-store/Test/Unit/App/Request/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Store\Test\Unit\App\Request; use Magento\Framework\App\Request\Http; use Magento\Store\App\Request\PathInfoProcessor; use Magento\Store\App\Request\StorePathInfoValidator; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class PathInfoProcessorTest extends TestCase { /** * @var StorePathInfoValidator|MockObject */ private $storePathInfoValidatorMock; /** * @var PathInfoProcessor */ private $model; /** * @var Http|MockObject */ private $requestMock; /** * @var string */ private $storeCode; /** * @var string */ private $pathInfo; protected function setUp(): void { $this->storePathInfoValidatorMock = $this->createMock(StorePathInfoValidator::class); $this->model = new PathInfoProcessor($this->storePathInfoValidatorMock); $this->requestMock = $this->createMock(Http::class); $this->storeCode = 'storeCode'; $this->pathInfo = '/' . $this->storeCode . '/node_one/'; } public function testProcessIfStoreIsEmpty(): void { $this->storePathInfoValidatorMock->expects($this->once()) ->method('getValidStoreCode') ->willReturn(null); $pathInfo = $this->model->process($this->requestMock, $this->pathInfo); $this->assertEquals($this->pathInfo, $pathInfo); } public function testProcessIfStoreExistsAndIsNotDirectAccessToFrontName(): void { $this->storePathInfoValidatorMock->expects($this->once()) ->method('getValidStoreCode') ->willReturn($this->storeCode); $this->requestMock->expects($this->atLeastOnce()) ->method('isDirectAccessFrontendName') ->with($this->storeCode) ->willReturn(false); $pathInfo = $this->model->process($this->requestMock, $this->pathInfo); $this->assertEquals('/node_one/', $pathInfo); } public function testProcessIfStoreExistsAndDirectAccessToFrontName(): void { $this->storePathInfoValidatorMock->expects($this->once()) ->method('getValidStoreCode') ->willReturn($this->storeCode); $this->requestMock->expects($this->atLeastOnce()) ->method('isDirectAccessFrontendName') ->with($this->storeCode) ->willReturn(true); $this->requestMock->expects($this->once()) ->method('setActionName') ->with('noroute'); $pathInfo = $this->model->process($this->requestMock, $this->pathInfo); $this->assertEquals($this->pathInfo, $pathInfo); } }