Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PreferencesResolvingTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class PreferencesResolvingTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testEmptyConfigModify()
14  {
15  $inputConfig = [
16  'data' => []
17  ];
18 
19  $modification = new PreferencesResolving();
20  $this->assertSame($inputConfig, $modification->modify($inputConfig));
21  }
22 
24  {
25  $inputConfig = [
26  'arguments' => $this->getInputArguments(),
27  'preferences' => $this->getPreferences()
28  ];
29  $outputConfig = [
30  'arguments' => $this->getOutputArguments(),
31  'preferences' => $this->getPreferences()
32  ];
33 
34  $modification = new PreferencesResolving();
35  $this->assertEquals($outputConfig, $modification->modify($inputConfig));
36  }
37 
41  private function getInputArguments()
42  {
43  return [
44  'SimpleClass' => [
45  'type_dependency' => [
46  '_ins_' => 'Type\DependencyInterface',
47  ],
48  'type_dependency_shared' => [
49  '_i_' => 'Type\Dependency\SharedInterface',
50  ],
51  'value' => [
52  '_v_' => 'value',
53  ],
54  'value_array' => [
55  '_v_' => ['default_value1', 'default_value2'],
56  ],
57  'value_null' => [
58  '_vn_' => true,
59  ],
60  'virtual_preferece' => [
61  '_i_' => 'Type\DependencyInterface2'
62  ]
63  ],
64  'ComplexClass' => [
65  'type_dependency_configured' => [
66  '_ins_' => 'Type\Dependency\ConfiguredInterface',
67  ],
68  'type_dependency_shared_configured' => [
69  '_i_' => 'Type\Dependency\Shared\Configured',
70  ],
71  'global_argument' => [
72  '_a_' => 'global_argument_configured',
73  '_d_' => null
74  ],
75  'global_argument_def' => [
76  '_a_' => 'global_argument_configured',
77  '_d_' => []
78  ],
79  'value_configured' => [
80  '_v_' => 'value_configured',
81  ],
82  'value_array_configured' => [
83  '_vac_' => [
84  'array_value' => 'value',
85  'array_configured_instance' => [
86  '_i_' => 'Type\Dependency\Shared\ConfiguredInterface',
87  ],
88  'array_configured_array' => [
89  'array_array_value' => 'value',
90  'array_array_configured_instance' => [
91  '_ins_' => 'Type\Dependency\Shared\Configured',
92  ],
93  ],
94  'array_global_argument' => [
95  '_a_' => 'global_argument_configured',
96  '_d_' => null
97  ]
98  ],
99  ],
100  'value_null' => [
101  '_vn_' => true,
102  ],
103  ]
104  ];
105  }
106 
110  private function getOutputArguments()
111  {
112  return [
113  'SimpleClass' => [
114  'type_dependency' => [
115  '_ins_' => 'Type\Dependency',
116  ],
117  'type_dependency_shared' => [
118  '_i_' => 'Type\Dependency\Shared',
119  ],
120  'value' => [
121  '_v_' => 'value',
122  ],
123  'value_array' => [
124  '_v_' => ['default_value1', 'default_value2'],
125  ],
126  'value_null' => [
127  '_vn_' => true,
128  ],
129  'virtual_preferece' => [
130  '_i_' => 'Type\DependencyVirtual3'
131  ]
132  ],
133  'ComplexClass' => [
134  'type_dependency_configured' => [
135  '_ins_' => 'Type\Dependency\Configured',
136  ],
137  'type_dependency_shared_configured' => [
138  '_i_' => 'Type\Dependency\Shared\ConfiguredPreference',
139  ],
140  'global_argument' => [
141  '_a_' => 'global_argument_configured',
142  '_d_' => null
143  ],
144  'global_argument_def' => [
145  '_a_' => 'global_argument_configured',
146  '_d_' => []
147  ],
148  'value_configured' => [
149  '_v_' => 'value_configured',
150  ],
151  'value_array_configured' => [
152  '_vac_' => [
153  'array_value' => 'value',
154  'array_configured_instance' => [
155  '_i_' => 'Type\Dependency\Shared\ConfiguredPreference',
156  ],
157  'array_configured_array' => [
158  'array_array_value' => 'value',
159  'array_array_configured_instance' => [
160  '_ins_' => 'Type\Dependency\Shared\ConfiguredPreference',
161  ],
162  ],
163  'array_global_argument' => [
164  '_a_' => 'global_argument_configured',
165  '_d_' => null
166  ]
167  ],
168  ],
169  'value_null' => [
170  '_vn_' => true,
171  ],
172  ]
173  ];
174  }
175 
179  private function getPreferences()
180  {
181  return [
182  'Type\DependencyInterface' => 'Type\Dependency',
183  'Type\Dependency\SharedInterface' => 'Type\Dependency\Shared',
184  'Type\Dependency\ConfiguredInterface' => 'Type\Dependency\Configured',
185  'Type\Dependency\Shared\ConfiguredInterface' => 'Type\Dependency\Shared\ConfiguredPreference',
186  'Type\Dependency\Shared\Configured' => 'Type\Dependency\Shared\ConfiguredPreference',
187  'Type\DependencyInterface2' => 'Type\DependencyVirtual',
188  'Type\DependencyVirtual' => 'Type\DependencyVirtual2',
189  'Type\DependencyVirtual2' => 'Type\DependencyVirtual3'
190  ];
191  }
192 }