public function testRemoveModulesFromDeploymentConfig() { $this->output->expects($this->atLeastOnce())->method('writeln'); $this->deploymentConfig->expects($this->once())->method('getConfigData')->willReturn(['moduleA' => 1, 'moduleB' => 1, 'moduleC' => 1, 'moduleD' => 1]); $this->loader->expects($this->once())->method('load')->willReturn(['moduleC' => [], 'moduleD' => []]); $this->writer->expects($this->once())->method('saveConfig')->with([ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['moduleC' => 1, 'moduleD' => 1]]]); $this->moduleRegistryUninstaller->removeModulesFromDeploymentConfig($this->output, ['moduleA', 'moduleB']); }
public function testChangeEncryptionKeyThrowsException() { $key = 'key'; $this->writerMock->expects($this->once())->method('checkIfWritable')->willReturn(false); try { $this->model->changeEncryptionKey($key); } catch (\Exception $e) { return; } $this->fail('An excpected exception was not signaled.'); }
private function setUpExecute($input) { $this->setUpPassValidation(); $this->remove->expects($this->once())->method('remove')->with(['magento/package-a', 'magento/package-b']); $this->dependencyChecker->expects($this->once()) ->method('checkDependenciesWhenDisableModules') ->willReturn(['Magento_A' => [], 'Magento_B' => []]); $this->dataSetup->expects($this->exactly(count($input['module'])))->method('deleteTableRow'); $this->deploymentConfig->expects($this->once()) ->method('getConfigData') ->with(ConfigOptionsListConstants::KEY_MODULES) ->willReturn(['Magento_A' => 1, 'Magento_B' => 1, 'Magento_C' => 0, 'Magento_D' => 1]); $this->loader->expects($this->once()) ->method('load') ->with($input['module']) ->willReturn(['Magento_C' => [], 'Magento_D' => []]); $this->writer->expects($this->once()) ->method('saveConfig') ->with( [ ConfigFilePool::APP_CONFIG => [ConfigOptionsListConstants::KEY_MODULES => ['Magento_C' => 0, 'Magento_D' => 1]] ] ); $this->cache->expects($this->once())->method('clean'); $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses'); }
public function testProcess() { $testSet1 = [ConfigFilePool::APP_CONFIG => ['segment' => ['someKey' => 'value', 'test' => 'value1']]]; $testSet2 = [ConfigFilePool::APP_CONFIG => ['segment' => ['test' => 'value2']]]; $testSetExpected = [ConfigFilePool::APP_CONFIG => ['segment' => ['someKey' => 'value', 'test' => 'value2']]]; $configData1 = clone $this->configData; $configData2 = clone $this->configData; $configData1->expects($this->any())->method('getData')->will($this->returnValue($testSet1[ConfigFilePool::APP_CONFIG])); $configData1->expects($this->any())->method('getFileKey')->will($this->returnValue(ConfigFilePool::APP_CONFIG)); $configData2->expects($this->any())->method('getData')->will($this->returnValue($testSet2[ConfigFilePool::APP_CONFIG])); $configData2->expects($this->any())->method('getFileKey')->will($this->returnValue(ConfigFilePool::APP_CONFIG)); $configOption = $this->configOptionsList; $configOption->expects($this->once())->method('createConfig')->will($this->returnValue([$configData1, $configData2])); $configOptionsList = ['Fake_Module' => $configOption]; $this->collector->expects($this->once())->method('collectOptionsLists')->will($this->returnValue($configOptionsList)); $this->writer->expects($this->once())->method('saveConfig')->with($testSetExpected); $this->configModel->process([]); }
/** * Prepare mocks for update modules tests and returns the installer to use * * @return Installer */ private function prepareForUpdateModulesTests() { $allModules = ['Foo_One' => [], 'Bar_Two' => [], 'New_Module' => []]; $cacheManager = $this->getMock('Magento\\Framework\\App\\Cache\\Manager', [], [], '', false); $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']); $cacheManager->expects($this->once())->method('clean'); $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([['Magento\\Framework\\App\\Cache\\Manager', $cacheManager]])); $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); $expectedModules = [ConfigFilePool::APP_CONFIG => ['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'New_Module' => 1]]]; $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); $newObject = $this->createObject(false, false); $this->configReader->expects($this->once())->method('load')->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0]]); $this->configWriter->expects($this->once())->method('saveConfig')->with($expectedModules); return $newObject; }
public function testUpdateModulesSequence() { $allModules = [ 'Foo_One' => [], 'Bar_Two' => [], 'New_Module' => [], ]; $this->cleanupFiles->expects($this->once())->method('clearCodeGeneratedClasses')->will( $this->returnValue( [ "The directory '/generation' doesn't exist - skipping cleanup", ] ) ); $cache = $this->getMock('Magento\Framework\App\Cache', [], [], '', false); $cache->expects($this->once())->method('clean'); $this->objectManager->expects($this->once()) ->method('create') ->will($this->returnValueMap([ ['Magento\Framework\App\Cache', [], $cache], ])); $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); $expectedModules = [ ConfigFilePool::APP_CONFIG => [ 'modules' => [ 'Bar_Two' => 0, 'Foo_One' => 1, 'New_Module' => 1 ] ] ]; $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); $newObject = $this->createObject(false, false); $this->configReader->expects($this->once())->method('load') ->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]); $this->configWriter->expects($this->once())->method('saveConfig')->with($expectedModules); $this->logger->expects($this->at(0))->method('log')->with('Cache cleared successfully'); $this->logger->expects($this->at(1))->method('log')->with('File system cleanup:'); $this->logger->expects($this->at(2))->method('log') ->with('The directory \'/generation\' doesn\'t exist - skipping cleanup'); $this->logger->expects($this->at(3))->method('log')->with('Updating modules:'); $newObject->updateModulesSequence(); }
public function testUpdateModulesSequence() { $varDir = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'); $varDir->expects($this->exactly(2))->method('getAbsolutePath')->willReturn('/var'); $this->filesystem->expects($this->exactly(2))->method('getDirectoryWrite')->willReturn($varDir); $allModules = ['Foo_One' => [], 'Bar_Two' => [], 'New_Module' => []]; $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); $expectedModules = ['Bar_Two' => 0, 'Foo_One' => 1, 'New_Module' => 1]; $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules)->willReturn($this->deploymentConfig); $newObject = $this->createObject(false, false); $this->configReader->expects($this->once())->method('load')->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0]]); $this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig); $this->logger->expects($this->at(0))->method('log')->with('File system cleanup:'); $this->logger->expects($this->at(1))->method('log')->with('The directory \'/var\' doesn\'t exist - skipping cleanup'); $this->logger->expects($this->at(3))->method('log')->with('Updating modules:'); $newObject->updateModulesSequence(); }