Skip to content

Commit a359c47

Browse files
author
Dmytro Aponasenko
committed
MTA-2343: Move all test data to repositories
1 parent e7cb546 commit a359c47

File tree

9 files changed

+45
-20
lines changed

9 files changed

+45
-20
lines changed

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct/BundleSelections.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
*/
1717
class BundleSelections extends DataSource
1818
{
19+
/**
20+
* Repository factory instance.
21+
*
22+
* @var RepositoryFactory
23+
*/
24+
protected $repositoryFactory;
25+
26+
/**
27+
* Fixture factory instance.
28+
*
29+
* @var RepositoryFactory
30+
*/
31+
protected $fixtureFactory;
32+
1933
/**
2034
* @constructor
2135
* @param RepositoryFactory $repositoryFactory
@@ -29,11 +43,24 @@ public function __construct(
2943
array $data,
3044
array $params = []
3145
) {
46+
$this->repositoryFactory = $repositoryFactory;
47+
$this->fixtureFactory = $fixtureFactory;
3248
$this->params = $params;
3349
$this->data = !isset($data['dataset']) ? $data : [];
50+
$this->getDataset($data);
51+
$this->prepareProducts();
52+
}
3453

54+
/**
55+
* Get dataset for a field.
56+
*
57+
* @param array $data
58+
* @return void
59+
*/
60+
protected function getDataset(array $data)
61+
{
3562
if (isset($data['dataset']) && isset($this->params['repository'])) {
36-
$this->data = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
63+
$this->data = $this->repositoryFactory->get($this->params['repository'])->get($data['dataset']);
3764
if (!empty($data['products'])) {
3865
$this->data['products'] = [];
3966
$this->data['products'] = explode('|', $data['products']);
@@ -42,7 +69,15 @@ public function __construct(
4269
}
4370
}
4471
}
72+
}
4573

74+
/**
75+
* Prepare products for bundle items.
76+
*
77+
* @return void
78+
*/
79+
protected function prepareProducts()
80+
{
4681
if (!empty($this->data['products'])) {
4782
$productsSelections = $this->data['products'];
4883
$this->data['products'] = [];
@@ -54,7 +89,7 @@ public function __construct(
5489
continue;
5590
}
5691
list($fixture, $dataset) = explode('::', $product);
57-
$productSelection[$key] = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
92+
$productSelection[$key] = $this->fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
5893
$productSelection[$key]->persist();
5994
$this->data['bundle_options'][$index]['assigned_products'][$key]['search_data']['name'] =
6095
$productSelection[$key]->getName();

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/Price.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public function __construct(RepositoryFactory $repositoryFactory, array $params,
3838

3939
if (isset($data['value'])) {
4040
$this->data = $data['value'];
41-
// if (is_array($this->data)) {
42-
// $this->data = array_filter(
43-
// $this->data,
44-
// function ($value) {
45-
// return $value !== '-';
46-
// }
47-
// );
48-
// }
4941
}
5042

5143
if (isset($data['dataset']) && isset($this->params['repository'])) {

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/NavigateUpSellProductsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use Magento\Mtf\Fixture\InjectableFixture;
1010

1111
/**
12-
* Test Flow:
13-
*
1412
* Preconditions:
1513
* 1. Create products.
1614
* 2. Assign promoted products.

dev/tests/functional/tests/app/Magento/Cms/Test/Fixture/CmsPage/Content.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class Content extends DataSource
3131
* @param FixtureFactory $fixtureFactory
3232
* @param array $params
3333
* @param array $data
34+
*
35+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3436
*/
3537
public function __construct(
3638
RepositoryFactory $repositoryFactory,

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/ConfigurableProduct/ConfigurableAttributesData.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Magento\Mtf\Fixture\InjectableFixture;
1313
use Magento\Mtf\Repository\RepositoryFactory;
1414
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
15-
use Magento\Catalog\Test\Fixture\CatalogProductAttribute;
1615

1716
/**
1817
* Source configurable attributes data of the configurable products.
@@ -94,7 +93,7 @@ public function __construct(
9493
*/
9594
protected function prepareAttributes(array $data)
9695
{
97-
if (isset($data['attributes'])) {
96+
if (!isset($data['attributes'])) {
9897
return;
9998
}
10099

@@ -145,7 +144,7 @@ protected function prepareAttributesData(array $data)
145144
*/
146145
protected function prepareProducts(array $data)
147146
{
148-
if (isset($data['products'])) {
147+
if (!isset($data['products'])) {
149148
return;
150149
}
151150

dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
* See COPYING.txt for license details.
66
*/
77
-->
8-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9-
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
109
<testCase name="Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest">
1110
<variation name="CreateConfigurableProductEntityTestVariation1">
1211
<data name="description" xsi:type="string">Create product with category and two new options</data>

dev/tests/functional/tests/app/Magento/Downloadable/Test/Fixture/DownloadableProduct.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<field name="samples_title" is_required="1" />
6565
<field name="short_description" is_required="0" group="autosettings" />
6666
<field name="downloadable" is_required="0" group="downloadable_information" />
67-
<field name="downloadable_links" is_required="0" group="downloadable_information" source="Magento\Downloadable\Test\Fixture\DownloadableProduct\Links" />
67+
<field name="downloadable_links" is_required="0" group="downloadable_information" repository="Magento\Downloadable\Test\Repository\DownloadableProduct\Links" />
6868
<field name="downloadable_sample" is_required="0" group="downloadable_information" repository="Magento\Downloadable\Test\Repository\DownloadableProduct\Samples" />
6969
<field name="sku" is_required="1" group="product-details" />
7070
<field name="small_image" is_required="0" />

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<field name="country_of_manufacture" is_required="0" />
2929
<field name="created_at" is_required="1" />
3030
<field name="custom_design" is_required="0" />
31-
<field name="associated" is_required="1" group="grouped" source="Magento\GroupedProduct\Test\Fixture\GroupedProduct\Associated" repository="Magento\GroupedProduct\Test\Fixture\GroupedProduct\Associated" />
31+
<field name="associated" is_required="1" group="grouped" source="Magento\GroupedProduct\Test\Fixture\GroupedProduct\Associated" repository="Magento\GroupedProduct\Test\Repository\GroupedProduct\Associated" />
3232
<field name="custom_design_from" is_required="0" />
3333
<field name="custom_design_to" is_required="0" />
3434
<field name="custom_layout_update" is_required="0" />

dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Repository/GroupedProduct/Associated.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9-
<repository class="Magento\GroupedProduct\Test\Repository\Associated">
9+
<repository class="Magento\GroupedProduct\Test\Repository\GroupedProduct\Associated">
1010
<dataset name="defaultSimpleProduct">
1111
<field name="assigned_products" xsi:type="array">
1212
<item name="0" xsi:type="array">

0 commit comments

Comments
 (0)