Beispiel #1
0
 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $mockName = 'Test Product Name';
     $mockVersion = '0.0.0';
     $mockEdition = 'Test Edition';
     $mockUrl = 'http://test-url';
     $this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
     $this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
     $this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
     $this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
     $configValues = ['timeout' => 2, 'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')', 'referer' => $mockUrl];
     $lastUpdate = 0;
     $this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
     $this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
     $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
     $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
     $this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
     $this->deploymentConfig->expects($this->once())->method('get')->with(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE)->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
     if ($callInbox) {
         $this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
         $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
     } else {
         $this->inboxFactory->expects($this->never())->method('create');
         $this->inboxModel->expects($this->never())->method('parse');
     }
     $this->feed->checkUpdate();
 }
 public function testExecuteNoOptions()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
     $this->tester->execute([]);
     $expected = 'Enabling maintenance mode' . PHP_EOL . 'Not enough information provided to take backup.' . PHP_EOL . 'Disabling maintenance mode' . PHP_EOL;
     $this->assertSame($expected, $this->tester->getDisplay());
 }
 public function testExecuteNotInstalled()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
     $this->installerFactory->expects($this->never())->method('create');
     $tester = new CommandTester($this->command);
     $tester->execute([]);
     $this->assertStringMatchesFormat("Store settings can't be saved because the Magento application is not installed.%w", $tester->getDisplay());
 }
 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 testExecute()
 {
     $this->deploymentConfig->expects($this->once())->method('get')->willReturn('admin_qw12er');
     $commandTester = new CommandTester(new InfoAdminUriCommand($this->deploymentConfig));
     $commandTester->execute([]);
     $regexp = '/' . BackendFrontnameGenerator::ADMIN_AREA_PATH_PREFIX . '[a-z0-9]{1,' . BackendFrontnameGenerator::ADMIN_AREA_PATH_RANDOM_PART_LENGTH . '}/';
     $this->assertRegExp($regexp, $commandTester->getDisplay(), 'Unexpected Backend Frontname pattern.');
 }
 public function testExecuteNoConfig()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
     $this->installerFactory->expects($this->never())->method('create');
     $commandTester = new CommandTester(new DbDataUpgradeCommand($this->installerFactory, $this->deploymentConfig));
     $commandTester->execute([]);
     $this->assertStringMatchesFormat('No information is available: the application is not installed.%w', $commandTester->getDisplay());
 }
 public function testExecuteNotInstalled()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(false));
     $this->dbVersionInfo->expects($this->never())->method('getDbVersionErrors');
     $tester = new CommandTester($this->command);
     $tester->execute([]);
     $this->assertStringMatchesFormat('No information is available: the Magento application is not installed.%w', $tester->getDisplay());
 }
Beispiel #8
0
 public function setUp()
 {
     $this->_connectionFactory = $this->getMockBuilder('Magento\\Framework\\Model\\Resource\\Type\\Db\\ConnectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->_config = $this->getMockBuilder('Magento\\Framework\\App\\Resource\\ConfigInterface')->disableOriginalConstructor()->setMethods(['getConnectionName'])->getMock();
     $this->_config->expects($this->any())->method('getConnectionName')->with(self::RESOURCE_NAME)->will($this->returnValue(self::CONNECTION_NAME));
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->deploymentConfig->expects($this->any())->method('get')->will($this->returnValue(['default' => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username'], self::CONNECTION_NAME => ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username']]));
     $this->connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->connection->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
     $this->resource = new Resource($this->_config, $this->_connectionFactory, $this->deploymentConfig, self::TABLE_PREFIX);
 }
 public function setUp()
 {
     $this->connectionFactory = $this->getMockBuilder(ConnectionFactoryInterface::class)->setMethods(['create'])->getMockForAbstractClass();
     $this->config = $this->getMockBuilder('Magento\\Framework\\App\\ResourceConnection\\ConfigInterface')->disableOriginalConstructor()->setMethods(['getConnectionName'])->getMock();
     $this->config->expects($this->any())->method('getConnectionName')->with(self::RESOURCE_NAME)->will($this->returnValue(self::CONNECTION_NAME));
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->deploymentConfig->expects($this->any())->method('get')->willReturnMap([[ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/connection-name', null, ['host' => 'localhost', 'dbname' => 'magento', 'username' => 'username']], [ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX, null, self::TABLE_PREFIX]]);
     $this->connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->connection->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
     $this->resource = new ResourceConnection($this->config, $this->connectionFactory, $this->deploymentConfig);
 }
 public function setUp()
 {
     $this->collector = $this->getMock('Magento\\Setup\\Model\\ConfigOptionsListCollector', [], [], '', false);
     $this->writer = $this->getMock('Magento\\Framework\\App\\DeploymentConfig\\Writer', [], [], '', false);
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->configOptionsList = $this->getMock('Magento\\Backend\\Setup\\ConfigOptionsList', [], [], '', false);
     $this->configData = $this->getMock('Magento\\Framework\\Config\\Data\\ConfigData', [], [], '', false);
     $this->filePermissions = $this->getMock('\\Magento\\Framework\\Setup\\FilePermissions', [], [], '', false);
     $this->deploymentConfig->expects($this->any())->method('get');
     $this->configModel = new ConfigModel($this->collector, $this->writer, $this->deploymentConfig, $this->filePermissions);
 }
Beispiel #11
0
 /**
  * @param string|null $fixtureSegment
  * @param string $inputCacheType
  * @param string $expectedFrontendId
  *
  * @dataProvider getDataProvider
  */
 public function testGet($fixtureSegment, $inputCacheType, $expectedFrontendId)
 {
     $this->_deploymentConfig->expects($this->once())->method('getSegment')->with(\Magento\Framework\App\DeploymentConfig\CacheConfig::CONFIG_KEY)->will($this->returnValue($fixtureSegment));
     $cacheFrontend = $this->getMock('Magento\\Framework\\Cache\\FrontendInterface');
     $this->_cachePool->expects($this->once())->method('get')->with($expectedFrontendId)->will($this->returnValue($cacheFrontend));
     $accessProxy = $this->getMock('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', [], [], '', false);
     $this->_objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', $this->identicalTo(['frontend' => $cacheFrontend, 'identifier' => $inputCacheType]))->will($this->returnValue($accessProxy));
     $this->assertSame($accessProxy, $this->_model->get($inputCacheType));
     // Result has to be cached in memory
     $this->assertSame($accessProxy, $this->_model->get($inputCacheType));
 }
Beispiel #12
0
 public function testSaveConfigOverride()
 {
     $configFiles = [ConfigFilePool::APP_CONFIG => 'test_conf.php', 'test_key' => 'test2_conf.php'];
     $testSetExisting = [ConfigFilePool::APP_CONFIG => ['foo' => 'bar', 'key' => 'value', 'baz' => ['test' => 'value', 'test1' => 'value1']]];
     $testSetUpdate = [ConfigFilePool::APP_CONFIG => ['baz' => ['test' => 'value2']]];
     $testSetExpected = [ConfigFilePool::APP_CONFIG => ['foo' => 'bar', 'key' => 'value', 'baz' => ['test' => 'value2']]];
     $this->deploymentConfig->expects($this->once())->method('resetData');
     $this->configFilePool->expects($this->once())->method('getPaths')->willReturn($configFiles);
     $this->dirWrite->expects($this->any())->method('isExist')->willReturn(true);
     $this->reader->expects($this->once())->method('load')->willReturn($testSetExisting[ConfigFilePool::APP_CONFIG]);
     $this->formatter->expects($this->once())->method('format')->with($testSetExpected[ConfigFilePool::APP_CONFIG])->willReturn([]);
     $this->dirWrite->expects($this->once())->method('writeFile')->with('test_conf.php', []);
     $this->object->saveConfig($testSetUpdate, true);
 }
Beispiel #13
0
 public function testIndexAction()
 {
     $this->objectManager = $this->getMockForAbstractClass('Magento\\Framework\\ObjectManagerInterface');
     $this->objectManagerProvider = $this->getMock('Magento\\Setup\\Model\\ObjectManagerProvider', ['get'], [], '', false);
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->objectManagerProvider->expects($this->once())->method('get')->willReturn($this->objectManager);
     $this->objectManager->expects($this->once())->method('get')->willReturn($this->deploymentConfig);
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
     /** @var $controller Index */
     $controller = new Index($this->objectManagerProvider);
     $viewModel = $controller->indexAction();
     $this->assertInstanceOf('Zend\\View\\Model\\ViewModel', $viewModel);
     $this->assertFalse($viewModel->terminate());
 }
 public function setUp()
 {
     $this->dbValidator = $this->getMock('Magento\\Setup\\Validator\\DbValidator', [], [], '', false);
     $this->deploymentConfig = $this->getMock('Magento\\Framework\\App\\DeploymentConfig', [], [], '', false);
     $this->deploymentConfig->expects($this->once())->method('get')->willReturn([ConfigOptionsListConstants::KEY_NAME => 'dbname', ConfigOptionsListConstants::KEY_HOST => 'host', ConfigOptionsListConstants::KEY_USER => 'username', ConfigOptionsListConstants::KEY_PASSWORD => 'password']);
     $this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->write = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', [], [], '', false);
     $this->filesystem->expects($this->once())->method('getDirectoryWrite')->willReturn($this->write);
     $this->phpReadinessCheck = $this->getMock('Magento\\Setup\\Model\\PhpReadinessCheck', [], [], '', false);
     $this->readinessCheck = new ReadinessCheck($this->dbValidator, $this->deploymentConfig, $this->filesystem, $this->phpReadinessCheck);
     $this->phpReadinessCheck->expects($this->once())->method('checkPhpVersion')->willReturn(['success' => true]);
     $this->phpReadinessCheck->expects($this->once())->method('checkPhpExtensions')->willReturn(['success' => true]);
     $this->phpReadinessCheck->expects($this->once())->method('checkPhpSettings')->willReturn(['success' => true]);
     $this->expected = [ReadinessCheck::KEY_PHP_VERSION_VERIFIED => ['success' => true], ReadinessCheck::KEY_PHP_EXTENSIONS_VERIFIED => ['success' => true], ReadinessCheck::KEY_PHP_SETTINGS_VERIFIED => ['success' => true]];
 }
    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 testExecute()
    {
        $this->objectManager->expects($this->once())
            ->method('get')
            ->with('Magento\Framework\App\Cache')
            ->willReturn($this->cacheMock);
        $this->cacheMock->expects($this->once())->method('clean');
        $writeDirectory = $this->getMock('Magento\Framework\Filesystem\Directory\WriteInterface');
        $writeDirectory->expects($this->atLeastOnce())->method('delete');
        $this->filesystem->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);

        $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
        $progressBar = $this->getMockBuilder(
            'Symfony\Component\Console\Helper\ProgressBar'
        )
            ->disableOriginalConstructor()
            ->getMock();

        $this->objectManager->expects($this->once())->method('configure');
        $this->objectManager
            ->expects($this->once())
            ->method('create')
            ->with('Symfony\Component\Console\Helper\ProgressBar')
            ->willReturn($progressBar);
        $this->manager->expects($this->exactly(6))->method('addOperation');
        $this->manager->expects($this->once())->method('process');
        $tester = new CommandTester($this->command);
        $tester->execute([]);
        $this->assertContains(
            'Generated code and dependency injection configuration successfully.',
            explode(PHP_EOL, $tester->getDisplay())
        );
    }
 private function setUpPassValidation()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
     $packageMap = [['Magento_A', 'magento/package-a'], ['Magento_B', 'magento/package-b']];
     $this->packageInfo->expects($this->any())->method('getPackageName')->will($this->returnValueMap($packageMap));
     $this->fullModuleList->expects($this->any())->method('has')->willReturn(true);
 }
 public function testBreakAfter()
 {
     $areaCode = 'frontend';
     $breakAfter = 5;
     $this->deploymentConfig->expects($this->once())->method('get')->with(Config::PARAM_BREAK_AFTER . '_' . $areaCode)->willReturn($breakAfter);
     $this->appState->expects($this->once())->method('getAreaCode')->willReturn($areaCode);
     $this->assertEquals($this->config->getBreakAfter(), $breakAfter);
 }
 public function setUpPreliminarySuccess()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(true);
     $this->readinessCheck->expects($this->once())->method('runReadinessCheck')->willReturn(true);
     $this->status->expects($this->once())->method('isUpdateInProgress')->willReturn(false);
     $this->status->expects($this->once())->method('isUpdateError')->willReturn(false);
     $this->status->expects($this->exactly(2))->method('toggleUpdateInProgress');
 }
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage ARG_IS_WRONG argument has invalid value, please run info:language:list
  */
 public function testExecuteInvalidLanguageArgument()
 {
     $this->deploymentConfig->expects($this->once())
         ->method('isAvailable')
         ->will($this->returnValue(true));
     $wrongParam = ['languages' => ['ARG_IS_WRONG']];
     $commandTester = new CommandTester($this->command);
     $commandTester->execute($wrongParam);
 }
 public function testInteraction()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
     $this->question->expects($this->once())->method('ask')->will($this->returnValue(false));
     $this->helperSet->expects($this->once())->method('get')->with('question')->will($this->returnValue($this->question));
     $this->command->setHelperSet($this->helperSet);
     $this->tester = new CommandTester($this->command);
     $this->tester->execute(['--db-file' => 'C.gz']);
 }
Beispiel #22
0
 public function testIndexActionNotInstalled()
 {
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
     $this->objectManagerProvider->expects($this->exactly(0))->method('get');
     /** @var $controller Index */
     $controller = new Index($this->objectManagerProvider, $this->deploymentConfig);
     $viewModel = $controller->indexAction();
     $this->assertInstanceOf('Zend\View\Model\ViewModel', $viewModel);
     $this->assertFalse($viewModel->terminate());
 }
 public function testExecute()
 {
     $this->directoryListMock->expects($this->atLeastOnce())->method('getPath')->willReturn(null);
     $this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Framework\\App\\Cache')->willReturn($this->cacheMock);
     $this->cacheMock->expects($this->once())->method('clean');
     $writeDirectory = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface');
     $writeDirectory->expects($this->atLeastOnce())->method('delete');
     $this->filesystemMock->expects($this->atLeastOnce())->method('getDirectoryWrite')->willReturn($writeDirectory);
     $this->deploymentConfigMock->expects($this->once())->method('get')->with(\Magento\Framework\Config\ConfigOptionsListConstants::KEY_MODULES)->willReturn(['Magento_Catalog' => 1]);
     $progressBar = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\ProgressBar')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock->expects($this->once())->method('configure');
     $this->objectManagerMock->expects($this->once())->method('create')->with('Symfony\\Component\\Console\\Helper\\ProgressBar')->willReturn($progressBar);
     $this->managerMock->expects($this->exactly(7))->method('addOperation');
     $this->managerMock->expects($this->once())->method('process');
     $tester = new CommandTester($this->command);
     $tester->execute([]);
     $this->assertContains('Generated code and dependency injection configuration successfully.', explode(PHP_EOL, $tester->getDisplay()));
     $this->assertSame(DiCompileCommand::NAME, $this->command->getName());
 }
 public function testCleanupDb()
 {
     $this->config->expects($this->once())->method('isAvailable')->willReturn(true);
     $this->config->expects($this->once())->method('getSegment')->with(DbConfig::CONFIG_KEY)->willReturn(self::$dbConfig);
     $this->connection->expects($this->at(0))->method('quoteIdentifier')->with('magento')->willReturn('`magento`');
     $this->connection->expects($this->at(1))->method('query')->with('DROP DATABASE IF EXISTS `magento`');
     $this->connection->expects($this->at(2))->method('query')->with('CREATE DATABASE IF NOT EXISTS `magento`');
     $this->logger->expects($this->once())->method('log')->with('Recreating database `magento`');
     $this->object->cleanupDb();
 }
Beispiel #25
0
 /**
  * @dataProvider checkUpdateDataProvider
  * @param bool $callInbox
  * @param string $curlRequest
  */
 public function testCheckUpdate($callInbox, $curlRequest)
 {
     $lastUpdate = 1410121748;
     $this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
     $this->curl->expects($this->any())->method('read')->will($this->returnValue($curlRequest));
     $this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
     $this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
     $this->backendConfig->expects($this->at(1))->method('getValue')->will($this->returnValue('http://feed.magento.com'));
     $this->cacheManager->expects($this->once())->method('load')->will($this->returnValue($lastUpdate));
     $this->deploymentConfig->expects($this->once())->method('get')->with('install/date')->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
     if ($callInbox) {
         $this->inboxFactory->expects($this->once())->method('create')->will($this->returnValue($this->inboxModel));
         $this->inboxModel->expects($this->once())->method('parse')->will($this->returnSelf());
     } else {
         $this->inboxFactory->expects($this->never())->method('create');
         $this->inboxModel->expects($this->never())->method('parse');
     }
     $this->feed->checkUpdate();
 }
 /**
  * @dataProvider validateDataProvider
  * @param array $option
  * @param string $error
  */
 public function testExecuteInvalidData(array $option, $error)
 {
     $url = $this->getMock('Magento\\Framework\\Url\\Validator', [], [], '', false);
     $url->expects($this->any())->method('isValid')->will($this->returnValue(false));
     if (!isset($option['--' . StoreConfigurationDataMapper::KEY_BASE_URL_SECURE])) {
         $url->expects($this->any())->method('getMessages')->will($this->returnValue([Validator::INVALID_URL => 'Invalid URL.']));
     }
     $localeLists = $this->getMock('Magento\\Framework\\Validator\\Locale', [], [], '', false);
     $localeLists->expects($this->any())->method('isValid')->will($this->returnValue(false));
     $timezoneLists = $this->getMock('Magento\\Framework\\Validator\\Timezone', [], [], '', false);
     $timezoneLists->expects($this->any())->method('isValid')->will($this->returnValue(false));
     $currencyLists = $this->getMock('Magento\\Framework\\Validator\\Currency', [], [], '', false);
     $currencyLists->expects($this->any())->method('isValid')->will($this->returnValue(false));
     $returnValueMapOM = [['Magento\\Framework\\Url\\Validator', $url], ['Magento\\Framework\\Validator\\Locale', $localeLists], ['Magento\\Framework\\Validator\\Timezone', $timezoneLists], ['Magento\\Framework\\Validator\\Currency', $currencyLists]];
     $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap($returnValueMapOM));
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
     $this->installerFactory->expects($this->never())->method('create');
     $commandTester = new CommandTester($this->command);
     $commandTester->execute($option);
     $this->assertEquals($error . PHP_EOL, $commandTester->getDisplay());
 }
 /**
  * @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']);
 }
Beispiel #28
0
 public function testCleanupDb()
 {
     $this->config->expects($this->once())->method('isAvailable')->willReturn(true);
     $this->config->expects($this->once())
         ->method('get')
         ->with(SetupConfigOptionsList::CONFIG_PATH_DB_CONNECTION_DEFAULT)
         ->willReturn(self::$dbConfig);
     $this->connection->expects($this->at(0))->method('quoteIdentifier')->with('magento')->willReturn('`magento`');
     $this->connection->expects($this->at(1))->method('query')->with('DROP DATABASE IF EXISTS `magento`');
     $this->connection->expects($this->at(2))->method('query')->with('CREATE DATABASE IF NOT EXISTS `magento`');
     $this->logger->expects($this->once())->method('log')->with('Cleaning up database `magento`');
     $this->object->cleanupDb();
 }
 public function testStartActionWithSampleDataError()
 {
     $this->webLogger->expects($this->once())->method('clear');
     $this->webLogger->expects($this->never())->method('logError');
     $this->deploymentConfig->expects($this->once())->method('isAvailable')->willReturn(false);
     $this->installer->method('install');
     $this->sampleDataState->expects($this->once())->method('hasError')->willReturn(true);
     $jsonModel = $this->controller->startAction();
     $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $this->assertTrue($jsonModel->getVariable('isSampleDataError'));
 }
 /**
  * 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;
 }