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']);
 }
 protected function setUp()
 {
     $this->packageInfoMock = $this->getMock('Magento\\Framework\\Module\\PackageInfo', [], [], '', false);
     $requireMap = [['A', ['B']], ['B', ['D', 'E']], ['C', ['E']], ['D', ['A']], ['E', []]];
     $this->packageInfoMock->expects($this->any())->method('getRequire')->will($this->returnValueMap($requireMap));
     $this->packageInfoFactoryMock = $this->getMock('Magento\\Framework\\Module\\PackageInfoFactory', [], [], '', false);
     $this->packageInfoFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->packageInfoMock));
     $this->listMock = $this->getMock('Magento\\Framework\\Module\\ModuleList', [], [], '', false);
     $this->loaderMock = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false);
     $this->loaderMock->expects($this->any())->method('load')->will($this->returnValue(['A' => [], 'B' => [], 'C' => [], 'D' => [], 'E' => []]));
 }
示例#3
0
 public function setUp()
 {
     $this->loader = $this->getMock('Magento\\Framework\\Module\\ModuleList\\Loader', [], [], '', false);
     $this->reader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', [], [], '', false);
     $this->loader->expects($this->once())->method('load')->will($this->returnValue(['A' => [], 'B' => [], 'C' => [], 'D' => [], 'E' => []]));
     $composerData = ['A/composer.json' => '{"name":"a", "require":{"b":"0.1"}, "conflict":{"c":"0.1"}, "version":"0.1"}', 'B/composer.json' => '{"name":"b", "require":{"d":"0.3"}, "version":"0.2"}', 'C/composer.json' => '{"name":"c", "require":{"e":"0.1"}, "version":"0.1"}', 'D/composer.json' => '{"name":"d", "conflict":{"c":"0.1"}, "version":"0.3"}', 'E/composer.json' => '{"name":"e", "version":"0.4"}'];
     $fileIteratorMock = $this->getMock('Magento\\Framework\\Config\\FileIterator', [], [], '', false);
     $fileIteratorMock->expects($this->once())->method('toArray')->will($this->returnValue($composerData));
     $this->reader->expects($this->once())->method('getComposerJsonFiles')->will($this->returnValue($fileIteratorMock));
     $this->packageInfo = new PackageInfo($this->loader, $this->reader, new \Magento\Framework\Stdlib\String());
 }
 /**
  * @param array $expectedAllModules
  * @param array $expectedConfig
  * @param array $expectedResult
  *
  * @dataProvider getAllModulesDataProvider
  */
 public function testSetIsEnabled($expectedAllModules, $expectedConfig, $expectedResult)
 {
     $this->moduleLoader->expects($this->once())->method('load')->will($this->returnValue($expectedAllModules));
     $this->deploymentConfig->expects($this->once())->method('get')->will($this->returnValue($expectedConfig));
     $this->dependencyChecker->expects($this->any())->method('checkDependenciesWhenDisableModules')->willReturn(['module1' => [], 'module2' => [], 'module3' => [], 'module4' => []]);
     $moduleStatus = new ModuleStatus($this->moduleLoader, $this->deploymentConfig, $this->objectManagerProvider);
     $moduleStatus->setIsEnabled(false, 'module1');
     $allModules = $moduleStatus->getAllModules();
     $this->assertSame(false, $allModules['module1']['selected']);
     $this->assertSame($expectedResult[1], $allModules['module2']['selected']);
     $this->assertSame($expectedResult[2], $allModules['module3']['selected']);
     $this->assertSame($expectedResult[3], $allModules['module4']['selected']);
 }
示例#5
0
 /**
  * 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;
 }
示例#6
0
    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();
 }
    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');

    }