/**
     * @param bool $isEnable
     * @param bool $clearStaticContent
     * @param string $expectedMessage
     *
     * @dataProvider executeDataProvider
     */
    public function testExecute($isEnable, $clearStaticContent, $expectedMessage)
    {
        $this->status->expects($this->once())
            ->method('getModulesToChange')
            ->with($isEnable, ['Magento_Module1', 'Magento_Module2'])
            ->will($this->returnValue(['Magento_Module1']));

        $this->status->expects($this->any())
            ->method('checkConstraints')
            ->will($this->returnValue([]));

        $this->status->expects($this->once())
            ->method('setIsEnabled')
            ->with($isEnable, ['Magento_Module1']);

        $this->cache->expects($this->once())
            ->method('clean');
        $this->cleanupFiles->expects($this->once())
            ->method('clearCodeGeneratedClasses');
        $this->cleanupFiles->expects($clearStaticContent ? $this->once() : $this->never())
            ->method('clearMaterializedViewFiles');

        $commandTester = $isEnable
            ? new CommandTester(new ModuleEnableCommand($this->objectManagerProvider))
            : new CommandTester(new ModuleDisableCommand($this->objectManagerProvider));
        $input = ['module' => ['Magento_Module1', 'Magento_Module2']];
        if ($clearStaticContent) {
            $input['--clear-static-content'] = true;
        }
        $commandTester->execute($input);
        $this->assertStringMatchesFormat($expectedMessage, $commandTester->getDisplay());
    }
 public function testExecuteCleanStaticFiles()
 {
     $this->setUpExecute();
     $this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles');
     $this->tester->execute(['theme' => ['test'], '-c' => true]);
     $this->assertContains('Enabling maintenance mode', $this->tester->getDisplay());
     $this->assertContains('Disabling maintenance mode', $this->tester->getDisplay());
     $this->assertNotContains('Alert: Generated static view files were not cleared.', $this->tester->getDisplay());
     $this->assertContains('Generated static view files cleared successfully', $this->tester->getDisplay());
 }
 public function testExecuteAll()
 {
     $input = ['module' => ['Magento_A', 'Magento_B'], '-c' => true, '-r' => true];
     $this->setUpExecute();
     $this->moduleUninstaller->expects($this->once())->method('uninstallData')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleUninstaller->expects($this->once())->method('uninstallCode')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDb')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->moduleRegistryUninstaller->expects($this->once())->method('removeModulesFromDeploymentConfig')->with($this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $input['module']);
     $this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles');
     $this->tester->execute($input);
 }
 public function testExecuteAll()
 {
     $input = ['module' => ['Magento_A', 'Magento_B'], '-c' => true, '-r' => true];
     $this->setUpExecute($input);
     $this->cleanupFiles->expects($this->once())->method('clearMaterializedViewFiles');
     $uninstallMock = $this->getMockForAbstractClass('Magento\Framework\Setup\UninstallInterface', [], '', false);
     $uninstallMock->expects($this->once())
         ->method('uninstall')
         ->with($this->setup, $this->isInstanceOf('Magento\Setup\Model\ModuleContext'));
     $this->uninstallCollector->expects($this->once())
         ->method('collectUninstall')
         ->willReturn(['Magento_A' => $uninstallMock]);
     $this->tester->execute($input);
 }
Esempio n. 5
0
    public function testUninstall()
    {
        $this->configReader->expects($this->once())->method('getFiles')->willReturn(['ConfigOne.php', 'ConfigTwo.php']);
        $configDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface');
        $configDir
            ->expects($this->exactly(2))
            ->method('getAbsolutePath')
            ->will(
                $this->returnValueMap(
                    [
                        ['ConfigOne.php', '/config/ConfigOne.php'],
                        ['ConfigTwo.php', '/config/ConfigTwo.php']
                    ]
                )
            );
        $this->filesystem
            ->expects($this->any())
            ->method('getDirectoryWrite')
            ->will($this->returnValueMap([
                [DirectoryList::CONFIG, DriverPool::FILE, $configDir],
            ]));
        $this->logger->expects($this->at(0))->method('log')->with('Starting Magento uninstallation:');
        $this->logger
            ->expects($this->at(2))
            ->method('log')
            ->with('No database connection defined - skipping database cleanup');
        $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')
            ->with('Magento\Framework\App\Cache\Manager')
            ->willReturn($cacheManager);
        $this->logger->expects($this->at(1))->method('log')->with('Cache cleared successfully');
        $this->logger->expects($this->at(3))->method('log')->with('File system cleanup:');
        $this->logger
            ->expects($this->at(4))
            ->method('log')
            ->with("The directory '/var' doesn't exist - skipping cleanup");
        $this->logger
            ->expects($this->at(5))
            ->method('log')
            ->with("The directory '/static' doesn't exist - skipping cleanup");
        $this->logger
            ->expects($this->at(6))
            ->method('log')
            ->with("The file '/config/ConfigOne.php' doesn't exist - skipping cleanup");
        $this->logger
            ->expects($this->at(7))
            ->method('log')
            ->with("The file '/config/ConfigTwo.php' doesn't exist - skipping cleanup");
        $this->logger->expects($this->once())->method('logSuccess')->with('Magento uninstallation complete.');
        $this->cleanupFiles->expects($this->once())->method('clearAllFiles')->will(
            $this->returnValue(
                [
                    "The directory '/var' doesn't exist - skipping cleanup",
                    "The directory '/static' doesn't exist - skipping cleanup"
                ]
            )
        );

        $this->object->uninstall();
    }