public function testProcess() { $path = 'design/head/logo'; $value = 'path/to/logo'; $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value])->willReturn($this->backendModel); $this->backendModel->expects($this->once())->method('afterLoad'); $this->backendModel->expects($this->once())->method('getValue')->willReturn($value); $this->assertEquals($value, $this->valueProcessor->process($value, $path)); }
public function testProcess() { $path = 'design/head/logo'; $value = 'path/to/logo'; $scope = 'websites'; $scopeId = 1; $this->backendModelFactory->expects($this->once())->method('createByPath')->with($path, ['value' => $value, 'field_config' => ['path' => $path], 'scope' => $scope, 'scope_id' => $scopeId])->willReturn($this->backendModel); $this->backendModel->expects($this->once())->method('afterLoad'); $this->backendModel->expects($this->once())->method('getValue')->willReturn($value); $this->assertEquals($value, $this->valueProcessor->process($value, $scope, $scopeId, ['path' => $path])); }
public function testCreate() { $scope = 'website'; $scopeId = 1; $data = ['scope' => $scope, 'scopeId' => $scopeId, 'value' => 'value', 'config' => ['path' => 'design/head/default_title', 'backend_model' => 'Magento\\Framework\\App\\Config\\Value']]; $this->metadataProviderMock->expects($this->once())->method('get')->willReturn(['head_default_title' => ['path' => 'design/head/default_title']]); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->collection); $this->collection->expects($this->once())->method('addPathsFilter')->with(['head_default_title' => 'design/head/default_title']); $this->collection->expects($this->once())->method('addFieldToFilter')->with('scope', $scope); $this->collection->expects($this->once())->method('addScopeIdFilter')->with($scopeId); $this->collection->expects($this->once())->method('getData')->willReturn([['config_id' => 1, 'path' => 'design/head/default_title']]); $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Config\\Value', ['data' => ['path' => 'design/head/default_title', 'scope' => $scope, 'scope_id' => $scopeId, 'field_config' => $data['config'], 'config_id' => 1]])->willReturn($this->backendModel); $this->backendModel->expects($this->once())->method('setValue')->willReturn('value'); $this->assertSame($this->backendModel, $this->model->create($data)); }
public function testValidateIsThemeInUse() { $theme = $this->getMock('Magento\\Theme\\Model\\Theme', [], [], '', false); $theme->expects($this->once())->method('getId')->willReturn(6); $defaultEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'default', 'scope_id' => 8]); $websitesEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'websites', 'scope_id' => 8]); $storesEntity = new \Magento\Framework\DataObject(['value' => 6, 'scope' => 'stores', 'scope_id' => 8]); $this->themeProvider->expects($this->once())->method('getThemeByFullPath')->willReturn($theme); $this->configData->expects($this->once())->method('getCollection')->willReturn($this->configData); $this->configData->expects($this->at(1))->method('addFieldToFilter')->willReturn($this->configData); $this->configData->expects($this->at(2))->method('addFieldToFilter')->willReturn([$defaultEntity, $websitesEntity, $storesEntity]); $website = $this->getMock('Magento\\Store\\Model\\Website', ['getName'], [], '', false); $website->expects($this->once())->method('getName')->willReturn('websiteA'); $store = $this->getMock('Magento\\Store\\Model\\Store', ['getName'], [], '', false); $store->expects($this->once())->method('getName')->willReturn('storeA'); $this->storeManager->expects($this->once())->method('getWebsite')->willReturn($website); $this->storeManager->expects($this->once())->method('getStore')->willReturn($store); $result = $this->themeValidator->validateIsThemeInUse(['frontend/Magento/a']); $this->assertEquals(['<error>frontend/Magento/a is in use in default config</error>', '<error>frontend/Magento/a is in use in website websiteA</error>', '<error>frontend/Magento/a is in use in store storeA</error>'], $result); }