-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from magento-ogre/PR_Branch
[Ogre] Magento CLI, Deployment Configuration Management Command
- Loading branch information
Showing
108 changed files
with
3,429 additions
and
1,943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Backend\Setup; | ||
|
||
use Magento\Framework\Config\Data\ConfigData; | ||
use Magento\Framework\Config\File\ConfigFilePool; | ||
use Magento\Framework\Setup\ConfigOptionsListInterface; | ||
use Magento\Framework\Setup\Option\TextConfigOption; | ||
use Magento\Framework\App\DeploymentConfig; | ||
|
||
/* | ||
* Deployment configuration options needed for Backend module | ||
*/ | ||
class ConfigOptionsList implements ConfigOptionsListInterface | ||
{ | ||
/** | ||
* Input key for the options | ||
*/ | ||
const INPUT_KEY_BACKEND_FRONTNAME = 'backend_frontname'; | ||
|
||
/** | ||
* Path to the values in the deployment config | ||
*/ | ||
const CONFIG_PATH_BACKEND_FRONTNAME = 'backend/frontName'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptions() | ||
{ | ||
return [ | ||
new TextConfigOption( | ||
self::INPUT_KEY_BACKEND_FRONTNAME, | ||
TextConfigOption::FRONTEND_WIZARD_TEXT, | ||
self::CONFIG_PATH_BACKEND_FRONTNAME, | ||
'Backend frontname', | ||
'admin' | ||
) | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function createConfig(array $options, DeploymentConfig $deploymentConfig) | ||
{ | ||
$configData = new ConfigData(ConfigFilePool::APP_CONFIG); | ||
|
||
if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME])) { | ||
$configData->set(self::CONFIG_PATH_BACKEND_FRONTNAME, $options[self::INPUT_KEY_BACKEND_FRONTNAME]); | ||
} | ||
|
||
return [$configData]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validate(array $options) | ||
{ | ||
$errors = []; | ||
if (isset($options[self::INPUT_KEY_BACKEND_FRONTNAME]) | ||
&& !preg_match('/^[a-zA-Z0-9_]+$/', $options[self::INPUT_KEY_BACKEND_FRONTNAME]) | ||
) { | ||
$errors[] = "Invalid backend frontname '{$options[self::INPUT_KEY_BACKEND_FRONTNAME]}'"; | ||
} | ||
|
||
return $errors; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/code/Magento/Backend/Test/Unit/Setup/ConfigOptionsListTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Backend\Test\Unit\Setup; | ||
|
||
use Magento\Backend\Setup\ConfigOptionsList; | ||
use Magento\Framework\Config\File\ConfigFilePool; | ||
|
||
class ConfigOptionsListTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ConfigOptionsList | ||
*/ | ||
private $object; | ||
|
||
/** | ||
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\DeploymentConfig | ||
*/ | ||
private $deploymentConfig; | ||
|
||
protected function setUp() | ||
{ | ||
$this->object = new ConfigOptionsList(); | ||
$this->deploymentConfig = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); | ||
} | ||
|
||
public function testGetOptions() | ||
{ | ||
$options = $this->object->getOptions(); | ||
$this->assertInternalType('array', $options); | ||
foreach ($options as $option) { | ||
$this->assertInstanceOf('\Magento\Framework\Setup\Option\AbstractConfigOption', $option); | ||
} | ||
} | ||
|
||
public function testCreateConfig() | ||
{ | ||
$options = [ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'admin']; | ||
$actualConfig = $this->object->createConfig($options, $this->deploymentConfig); | ||
|
||
$expectedData = [ | ||
[ | ||
'file' => ConfigFilePool::APP_CONFIG, | ||
'segment' => 'backend', | ||
'data' => [ | ||
'backend' => ['frontName' => 'admin'] | ||
] | ||
] | ||
]; | ||
|
||
$this->assertInternalType('array', $actualConfig); | ||
/** @var \Magento\Framework\Config\Data\ConfigData $config */ | ||
foreach ($actualConfig as $i => $config) { | ||
$this->assertInstanceOf('\Magento\Framework\Config\Data\ConfigData', $config); | ||
$this->assertSame($expectedData[$i]['file'], $config->getFileKey()); | ||
$this->assertSame($expectedData[$i]['data'], $config->getData()); | ||
} | ||
} | ||
|
||
public function testValidate() | ||
{ | ||
$options = [ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'admin']; | ||
$errors = $this->object->validate($options); | ||
$this->assertEmpty($errors); | ||
} | ||
|
||
/** | ||
* @param array $options | ||
* @param string $expectedError | ||
* @dataProvider validateInvalidDataProvider | ||
*/ | ||
public function testValidateInvalid(array $options, $expectedError) | ||
{ | ||
$errors = $this->object->validate($options); | ||
$this->assertSame([$expectedError], $errors); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function validateInvalidDataProvider() | ||
{ | ||
return [ | ||
[[ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => '**'], "Invalid backend frontname '**'"], | ||
[ | ||
[ConfigOptionsList::INPUT_KEY_BACKEND_FRONTNAME => 'invalid frontname'], | ||
"Invalid backend frontname 'invalid frontname'" | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Order deny,allow | ||
Deny from all |
Oops, something went wrong.