public function testGetData()
 {
     $object = new DeploymentConfig([]);
     $this->assertSame([], $object->getData());
     $object = new DeploymentConfig(['Module_One' => '1', 'Module_Two' => false]);
     $this->assertSame(['Module_One' => 1, 'Module_Two' => 0], $object->getData());
 }
Esempio n. 2
0
 public function testInstall()
 {
     $request = [DeploymentConfigMapper::KEY_DB_HOST => '127.0.0.1', DeploymentConfigMapper::KEY_DB_NAME => 'magento', DeploymentConfigMapper::KEY_DB_USER => 'magento', DeploymentConfigMapper::KEY_ENCRYPTION_KEY => 'encryption_key', DeploymentConfigMapper::KEY_BACKEND_FRONTNAME => 'backend'];
     $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true);
     $this->config->expects($this->any())->method('getSegment')->will($this->returnValueMap([[DbConfig::CONFIG_KEY, self::$dbConfig], [EncryptConfig::CONFIG_KEY, [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key']]]));
     $allModules = ['Foo_One' => [], 'Bar_Two' => []];
     $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules);
     $modules = ['Foo_One' => 1, 'Bar_Two' => 1];
     $this->deploymentConfig->expects($this->any())->method('getData')->willReturn($modules);
     $this->deploymentConfigFactory->expects($this->any())->method('create')->with($modules)->willReturn($this->deploymentConfig);
     $setup = $this->getMock('Magento\\Setup\\Module\\Setup', [], [], '', false);
     $table = $this->getMock('Magento\\Framework\\DB\\Ddl\\Table', [], [], '', false);
     $connection = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $setup->expects($this->any())->method('getConnection')->willReturn($connection);
     $table->expects($this->any())->method('addColumn')->willReturn($table);
     $table->expects($this->any())->method('setComment')->willReturn($table);
     $table->expects($this->any())->method('addIndex')->willReturn($table);
     $connection->expects($this->any())->method('newTable')->willReturn($table);
     $resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->contextMock->expects($this->any())->method('getResources')->willReturn($resource);
     $resource->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $dataSetup = $this->getMock('Magento\\Setup\\Module\\DataSetup', [], [], '', false);
     $cacheManager = $this->getMock('Magento\\Framework\\App\\Cache\\Manager', [], [], '', false);
     $cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['foo', 'bar']);
     $cacheManager->expects($this->once())->method('setEnabled')->willReturn(['foo', 'bar']);
     $this->objectManager->expects($this->any())->method('create')->will($this->returnValueMap([['Magento\\Setup\\Module\\Setup', ['resource' => $resource], $setup], ['Magento\\Setup\\Module\\DataSetup', [], $dataSetup], ['Magento\\Framework\\App\\Cache\\Manager', [], $cacheManager]]));
     $this->adminFactory->expects($this->once())->method('create')->willReturn($this->getMock('Magento\\Setup\\Model\\AdminAccount', [], [], '', false));
     $this->logger->expects($this->at(0))->method('log')->with('Starting Magento installation:');
     $this->logger->expects($this->at(1))->method('log')->with('File permissions check...');
     // at(2) invokes logMeta()
     $this->logger->expects($this->at(3))->method('log')->with('Enabling Maintenance Mode...');
     // at(4) - logMeta and so on...
     $this->logger->expects($this->at(5))->method('log')->with('Installing deployment configuration...');
     $this->logger->expects($this->at(7))->method('log')->with('Installing database schema:');
     $this->logger->expects($this->at(9))->method('log')->with("Module 'Foo_One':");
     $this->logger->expects($this->at(11))->method('log')->with("Module 'Bar_Two':");
     $this->logger->expects($this->at(13))->method('log')->with('Schema post-updates:');
     $this->logger->expects($this->at(14))->method('log')->with("Module 'Foo_One':");
     $this->logger->expects($this->at(16))->method('log')->with("Module 'Bar_Two':");
     $this->logger->expects($this->at(19))->method('log')->with('Installing user configuration...');
     $this->logger->expects($this->at(21))->method('log')->with('Installing data...');
     $this->logger->expects($this->at(22))->method('log')->with('Data install/update:');
     $this->logger->expects($this->at(23))->method('log')->with("Module 'Foo_One':");
     $this->logger->expects($this->at(25))->method('log')->with("Module 'Bar_Two':");
     $this->logger->expects($this->at(28))->method('log')->with('Installing admin user...');
     $this->logger->expects($this->at(30))->method('log')->with('Enabling caches:');
     $this->logger->expects($this->at(31))->method('log')->with('Current status:');
     $this->logger->expects($this->at(34))->method('log')->with('Disabling Maintenance Mode:');
     $this->logger->expects($this->at(36))->method('log')->with('Post installation file permissions check...');
     $this->logger->expects($this->once())->method('logSuccess')->with('Magento installation complete.');
     $this->object->install($request);
 }