Skip to content

Commit f9cb8ad

Browse files
fixing static tests
1 parent 884dcc0 commit f9cb8ad

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

setup/src/Magento/Setup/Fixtures/FixtureModel.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@
1919
*/
2020
class FixtureModel
2121
{
22-
/**
23-
* Area code
24-
*/
25-
const AREA_CODE = 'adminhtml';
22+
public const AREA_CODE = 'adminhtml';
2623

2724
/**
2825
* Fixtures file name pattern
2926
*/
30-
const FIXTURE_PATTERN = '?*Fixture.php';
27+
private const FIXTURE_PATTERN = '?*Fixture.php';
3128

3229
/**
3330
* Application object
@@ -121,13 +118,18 @@ public function loadFixtures()
121118
);
122119
$this->loadFixture($fixture);
123120
}
124-
foreach($this->getFixturesFromRegistry() as $fixture) {
121+
foreach ($this->getFixturesFromRegistry() as $fixture) {
125122
$this->loadFixture($fixture);
126123
}
127124
ksort($this->fixtures);
128125
return $this;
129126
}
130127

128+
/**
129+
* Gets Fixtures from FixtureRegistry and gets instances of them from ObjectManager
130+
*
131+
* @return array
132+
*/
131133
private function getFixturesFromRegistry() : array
132134
{
133135
$fixtureRegistry = $this->getObjectManager()->create(FixtureRegistry::class);
@@ -141,6 +143,12 @@ private function getFixturesFromRegistry() : array
141143
return $fixtures;
142144
}
143145

146+
/**
147+
* Loads fixture into $this->>fixturesByName and $this->fixtures
148+
*
149+
* @param Fixture $fixture
150+
* @return void
151+
*/
144152
private function loadFixture(Fixture $fixture)
145153
{
146154
$fixtureClassName = get_class($fixture);
@@ -178,7 +186,8 @@ public function getFixtures()
178186

179187
/**
180188
* Returns fixture by name
181-
* @param $name string
189+
*
190+
* @param string $name
182191
* @return Fixture
183192
* @throws \Magento\Setup\Exception
184193
*/
@@ -253,14 +262,15 @@ public function resetObjectManager()
253262
}
254263

255264
/**
265+
* Gets instance of FixtureConfig from ObjectManager
266+
*
256267
* @return FixtureConfig
257268
*/
258269
private function getConfig()
259270
{
260271
if (null === $this->config) {
261272
$this->config = $this->getObjectManager()->get(FixtureConfig::class);
262273
}
263-
264274
return $this->config;
265275
}
266276

setup/src/Magento/Setup/Fixtures/FixtureRegistry.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
declare(strict_types=1);
8+
79
/**
810
* Registry for fixtures
911
*/
@@ -15,12 +17,12 @@ class FixtureRegistry
1517
/**
1618
* List of fixtures applied to the application
1719
*
18-
* @var Fixture[]
20+
* @var string[]
1921
*/
2022
private $fixtures = [];
2123

2224
/**
23-
* @param array $fixtures
25+
* @param string[] $fixtures
2426
*/
2527
public function __construct(array $fixtures = [])
2628
{
@@ -36,5 +38,4 @@ public function getFixtures() :array
3638
{
3739
return $this->fixtures;
3840
}
39-
4041
}

setup/src/Magento/Setup/Fixtures/StoresFixture.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
*/
4242
class StoresFixture extends Fixture
4343
{
44-
const DEFAULT_WEBSITE_COUNT = 1;
44+
private const DEFAULT_WEBSITE_COUNT = 1;
4545

46-
const DEFAULT_STORE_COUNT = 1;
46+
private const DEFAULT_STORE_COUNT = 1;
4747

48-
const DEFAULT_STORE_VIEW_COUNT = 1;
48+
private const DEFAULT_STORE_VIEW_COUNT = 1;
4949

5050
/**
5151
* @var int
@@ -132,7 +132,6 @@ class StoresFixture extends Fixture
132132
*/
133133
private $storeViewIds;
134134

135-
136135
/**
137136
* @var string[]
138137
*/
@@ -179,7 +178,8 @@ public function __construct(
179178
}
180179

181180
/**
182-
* {@inheritdoc}
181+
* @inheritdoc
182+
*
183183
* @SuppressWarnings(PHPMD)
184184
*/
185185
public function execute()
@@ -195,17 +195,13 @@ public function execute()
195195
) {
196196
return;
197197
}
198-
199198
//Get existing entities counts
200199
$storeGroups = $this->storeManager->getGroups();
201200
$this->storeGroupsIds= array_keys($storeGroups);
202-
203201
foreach ($storeGroups as $storeGroupId => $storeGroup) {
204202
$this->storeGroupsToWebsites[$storeGroupId] = $storeGroup->getWebsiteId();
205203
}
206-
207204
$this->websiteIds = array_values(array_unique($this->storeGroupsToWebsites));
208-
209205
$this->defaultWebsite = $this->storeManager->getWebsite();
210206
$this->defaultStoreGroup = $this->storeManager->getGroup();
211207
$this->defaultWebsiteId = $this->defaultWebsite->getId();
@@ -219,6 +215,7 @@ public function execute()
219215

220216
/**
221217
* Generating web sites
218+
*
222219
* @return void
223220
*/
224221
private function generateWebsites()
@@ -245,18 +242,17 @@ private function generateWebsites()
245242

246243
/**
247244
* Generating store groups ('stores' on frontend)
245+
*
248246
* @return void
249247
*/
250248
private function generateStoreGroups()
251249
{
252250
$existedStoreGroupCount = count($this->storeGroupsIds);
253251
$existedWebsitesCount = count($this->websiteIds);
254-
255252
while ($existedStoreGroupCount < $this->storeGroupsCount) {
256253
$websiteId = $this->websiteIds[$existedStoreGroupCount % $existedWebsitesCount];
257254
$storeGroupName = sprintf('Store Group %d - website_id_%d', ++$existedStoreGroupCount, $websiteId);
258255
$storeGroupCode = sprintf('store_group_%d', $existedStoreGroupCount);
259-
260256
$storeGroup = clone $this->defaultStoreGroup;
261257
$storeGroup->addData(
262258
[
@@ -275,16 +271,15 @@ private function generateStoreGroups()
275271

276272
/**
277273
* Generating store views
274+
*
278275
* @return void
279276
*/
280277
private function generateStoreViews()
281278
{
282279
$localesList = $this->localeConfig->getAllowedLocales();
283280
$localesListCount = count($localesList);
284-
285281
$existedStoreViewsCount = count($this->storeViewIds);
286282
$existedStoreGroupCount = count($this->storeGroupsIds);
287-
288283
while ($existedStoreViewsCount < $this->storesCount) {
289284
$groupId = $this->storeGroupsIds[$existedStoreViewsCount % $existedStoreGroupCount];
290285
$websiteId = $this->storeGroupsToWebsites[$groupId];
@@ -296,7 +291,6 @@ private function generateStoreViews()
296291
$websiteId,
297292
$groupId
298293
);
299-
300294
$store->addData(
301295
[
302296
'store_id' => null,
@@ -306,12 +300,13 @@ private function generateStoreViews()
306300
'code' => $storeCode
307301
]
308302
)->save();
309-
310303
$this->saveStoreLocale($store->getId(), $localesList[$existedStoreViewsCount % $localesListCount]);
311304
}
312305
}
313306

314307
/**
308+
* Saves store into locale
309+
*
315310
* @param int $storeId
316311
* @param string $localeCode
317312
* @return void
@@ -347,21 +342,20 @@ private function getStoreCategoryId($storeGroupName)
347342
->setDefaultSortBy('name')
348343
->setIsActive(true)
349344
->save();
350-
351345
return $category->getId();
352346
}
353347
}
354348

355349
/**
356-
* {@inheritdoc}
350+
* @inheritdoc
357351
*/
358352
public function getActionTitle()
359353
{
360354
return 'Generating websites, stores and store views';
361355
}
362356

363357
/**
364-
* {@inheritdoc}
358+
* @inheritdoc
365359
*/
366360
public function introduceParamLabels()
367361
{
@@ -385,6 +379,11 @@ private function getDefaultCategoryId()
385379
return $this->defaultParentCategoryId;
386380
}
387381

382+
/**
383+
* Gets the website codes that were created by this object
384+
*
385+
* @return string[]
386+
*/
388387
public function getWebsiteCodes()
389388
{
390389
return $this->websiteCodes;

0 commit comments

Comments
 (0)