|
| __construct ($name=null, array $data=[], $dataName='') |
|
| testConstructorNonExistingBaseDir () |
|
| testGet ($settingName, $defaultValue, $expectedResult) |
|
| getDataProvider () |
|
| testGetAsBoolean ($settingName, $expectedResult) |
|
| getAsBooleanDataProvider () |
|
| testGetAsFile ($settingName, $defaultValue, $expectedResult) |
|
| getAsFileDataProvider () |
|
| testGetAsMatchingPaths ($settingName, $expectedResult) |
|
| getAsMatchingPathsDataProvider () |
|
| testGetAsConfigFile ($settingName, $expectedResult) |
|
| getAsConfigFileDataProvider () |
|
| testGetAsConfigFileException ($settingName, $expectedExceptionMsg) |
|
| getAsConfigFileExceptionDataProvider () |
|
Definition at line 12 of file SettingsTest.php.
◆ __construct()
__construct |
( |
|
$name = null , |
|
|
array |
$data = [] , |
|
|
|
$dataName = '' |
|
) |
| |
Define the fixture directory to be used in both data providers and tests
- Parameters
-
string | null | $name | |
array | $data | |
string | $dataName | |
Definition at line 31 of file SettingsTest.php.
34 $this->_fixtureDir = realpath(
__DIR__ .
'/_files') .
'/';
defined('TESTS_BP')||define('TESTS_BP' __DIR__
if(!isset($_GET['name'])) $name
◆ getAsBooleanDataProvider()
getAsBooleanDataProvider |
( |
| ) |
|
Definition at line 107 of file SettingsTest.php.
110 'non-enabled string' => [
'item_label',
false],
111 'non-enabled boolean' => [
'is_in_stock',
false],
112 'enabled string' => [
'free_shipping',
true]
◆ getAsConfigFileDataProvider()
getAsConfigFileDataProvider |
( |
| ) |
|
Definition at line 186 of file SettingsTest.php.
189 'config file & dist file' => [
'config_file_with_dist',
"{$this->_fixtureDir}1.xml"],
190 'config file & no dist file' => [
'config_file_no_dist',
"{$this->_fixtureDir}2.xml"],
191 'no config file & dist file' => [
'no_config_file_dist',
"{$this->_fixtureDir}3.xml.dist"]
◆ getAsConfigFileExceptionDataProvider()
getAsConfigFileExceptionDataProvider |
( |
| ) |
|
Definition at line 207 of file SettingsTest.php.
210 'non-existing setting' => [
212 __(
"Setting 'non_existing' specifies the non-existing file ''."),
214 'non-existing file' => [
216 __(
"Setting 'item_label' specifies the non-existing file '%1Item Label.dist'.", $this->_fixtureDir),
◆ getAsFileDataProvider()
getAsFileDataProvider |
( |
| ) |
|
Definition at line 127 of file SettingsTest.php.
130 'existing file' => [
'test_file',
'',
"{$this->_fixtureDir}metrics.php"],
131 'zero value setting' => [
'zero_value',
'default_should_be_ignored',
"{$this->_fixtureDir}0"],
132 'empty default value' => [
'non_existing_file',
'',
''],
133 'zero default value' => [
'non_existing_file',
'0',
"{$this->_fixtureDir}0"],
134 'default value' => [
'non_existing_file',
'metrics.php',
"{$this->_fixtureDir}metrics.php"]
◆ getAsMatchingPathsDataProvider()
getAsMatchingPathsDataProvider |
( |
| ) |
|
Definition at line 152 of file SettingsTest.php.
155 'single pattern' => [
157 [
"{$this->_fixtureDir}1.xml",
"{$this->_fixtureDir}2.xml"],
159 'pattern with braces' => [
160 'all_xml_or_one_php_file',
161 [
"{$this->_fixtureDir}1.xml",
"{$this->_fixtureDir}2.xml",
"{$this->_fixtureDir}4.php"],
163 'multiple patterns' => [
164 'one_xml_or_any_php_file',
165 [
"{$this->_fixtureDir}1.xml",
"{$this->_fixtureDir}4.php"],
167 'non-existing setting' => [
'non_existing', []],
168 'setting with zero value' => [
'zero_value', [
"{$this->_fixtureDir}0"]]
◆ getDataProvider()
Definition at line 84 of file SettingsTest.php.
87 'string type' => [
'item_label',
null,
'Item Label'],
88 'integer type' => [
'number_of_items',
null, 42],
89 'float type' => [
'item_price',
null, 12.99],
90 'boolean type' => [
'is_in_stock',
null,
true],
91 'non-existing' => [
'non_existing',
null,
null],
92 'zero string' => [
'zero_value',
'1',
'0'],
93 'default value' => [
'non_existing',
'default',
'default']
◆ setUp()
Definition at line 37 of file SettingsTest.php.
39 $this->_object = new \Magento\TestFramework\Bootstrap\Settings(
42 'item_label' =>
'Item Label',
43 'number_of_items' => 42,
44 'item_price' => 12.99,
45 'is_in_stock' =>
true,
46 'free_shipping' =>
'enabled',
48 'test_file' =>
'metrics.php',
49 'all_xml_files' =>
'*.xml',
50 'all_xml_or_one_php_file' =>
'{*.xml,4.php}',
51 'one_xml_or_any_php_file' =>
'1.xml;?.php',
52 'config_file_with_dist' =>
'1.xml',
53 'config_file_no_dist' =>
'2.xml',
54 'no_config_file_dist' =>
'3.xml'
◆ tearDown()
◆ testConstructorNonExistingBaseDir()
testConstructorNonExistingBaseDir |
( |
| ) |
|
@expectedException \InvalidArgumentException @expectedExceptionMessage Base path 'non_existing_dir' has to be an existing directory.
Definition at line 68 of file SettingsTest.php.
70 new \Magento\TestFramework\Bootstrap\Settings(
'non_existing_dir', []);
◆ testGet()
testGet |
( |
|
$settingName, |
|
|
|
$defaultValue, |
|
|
|
$expectedResult |
|
) |
| |
- Parameters
-
string | $settingName | |
mixed | $defaultValue | |
mixed | $expectedResult | @dataProvider getDataProvider |
Definition at line 79 of file SettingsTest.php.
81 $this->assertSame($expectedResult, $this->_object->get($settingName, $defaultValue));
◆ testGetAsBoolean()
testGetAsBoolean |
( |
|
$settingName, |
|
|
|
$expectedResult |
|
) |
| |
- Parameters
-
string | $settingName | |
bool | $expectedResult | @dataProvider getAsBooleanDataProvider |
Definition at line 102 of file SettingsTest.php.
104 $this->assertSame($expectedResult, $this->_object->getAsBoolean($settingName));
◆ testGetAsConfigFile()
testGetAsConfigFile |
( |
|
$settingName, |
|
|
|
$expectedResult |
|
) |
| |
- Parameters
-
string | $settingName | |
mixed | $expectedResult | @dataProvider getAsConfigFileDataProvider |
Definition at line 177 of file SettingsTest.php.
179 $actualResult = $this->_object->getAsConfigFile($settingName);
180 if (is_array($actualResult)) {
183 $this->assertEquals($expectedResult, $actualResult);
◆ testGetAsConfigFileException()
testGetAsConfigFileException |
( |
|
$settingName, |
|
|
|
$expectedExceptionMsg |
|
) |
| |
- Parameters
-
string | $settingName | |
string | $expectedExceptionMsg | @dataProvider getAsConfigFileExceptionDataProvider |
Definition at line 200 of file SettingsTest.php.
202 $this->expectException(\
Magento\Framework\Exception\LocalizedException::class);
203 $this->expectExceptionMessage((
string)$expectedExceptionMsg);
204 $this->_object->getAsConfigFile($settingName);
◆ testGetAsFile()
testGetAsFile |
( |
|
$settingName, |
|
|
|
$defaultValue, |
|
|
|
$expectedResult |
|
) |
| |
- Parameters
-
string | $settingName | |
mixed | $defaultValue | |
string | $expectedResult | @dataProvider getAsFileDataProvider |
Definition at line 122 of file SettingsTest.php.
124 $this->assertSame($expectedResult, $this->_object->getAsFile($settingName, $defaultValue));
◆ testGetAsMatchingPaths()
testGetAsMatchingPaths |
( |
|
$settingName, |
|
|
|
$expectedResult |
|
) |
| |
- Parameters
-
string | $settingName | |
string | $expectedResult | @dataProvider getAsMatchingPathsDataProvider |
Definition at line 143 of file SettingsTest.php.
145 $actualResult = $this->_object->getAsMatchingPaths($settingName);
146 if (is_array($actualResult)) {
149 $this->assertEquals($expectedResult, $actualResult);
◆ $_fixtureDir
◆ $_object
The documentation for this class was generated from the following file:
- vendor/magento/magento2-base/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/SettingsTest.php