storeManager = $this->getMockForAbstractClass( \Magento\Store\Model\StoreManagerInterface::class, [], '', false ); $this->urlBuilder = $this->getMockForAbstractClass( \Magento\Framework\UrlInterface::class, [], '', false ); $this->scopeConfig = $this->getMockForAbstractClass( \Magento\Framework\App\Config\ScopeConfigInterface::class, [], '', false ); $this->store = $this->getMockForAbstractClass( \Magento\Store\Api\Data\StoreInterface::class, [], '', false, false, true, ['getBaseUrl'] ); $this->customerUrl = $this->createMock(\Magento\Customer\Model\Url::class); $this->provider = new ConfigProvider( $this->urlBuilder, $this->storeManager, $this->scopeConfig, $this->customerUrl ); } public function testGetConfigWithoutRedirect() { $loginUrl = 'http://url.test/customer/login'; $baseUrl = 'http://base-url.test'; $this->customerUrl->expects($this->exactly(2)) ->method('getLoginUrl') ->willReturn($loginUrl); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($this->store); $this->store->expects($this->once()) ->method('getBaseUrl') ->willReturn($baseUrl); $this->scopeConfig->expects($this->once()) ->method('getValue') ->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE) ->willReturn(1); $this->assertEquals( [ 'customerLoginUrl' => $loginUrl, 'isRedirectRequired' => true, 'autocomplete' => 'on', ], $this->provider->getConfig() ); } public function testGetConfig() { $loginUrl = 'http://base-url.test/customer/login'; $baseUrl = 'http://base-url.test'; $this->customerUrl->expects($this->exactly(2)) ->method('getLoginUrl') ->willReturn($loginUrl); $this->storeManager->expects($this->once()) ->method('getStore') ->willReturn($this->store); $this->store->expects($this->once()) ->method('getBaseUrl') ->willReturn($baseUrl); $this->scopeConfig->expects($this->once()) ->method('getValue') ->with(Form::XML_PATH_ENABLE_AUTOCOMPLETE, ScopeInterface::SCOPE_STORE) ->willReturn(0); $this->assertEquals( [ 'customerLoginUrl' => $loginUrl, 'isRedirectRequired' => false, 'autocomplete' => 'off', ], $this->provider->getConfig() ); } }