Skip to content

Commit feea6f6

Browse files
committed
MC-40793: Update "Data fixture annotation" documentation
- Add documentation for new fixture classes
1 parent b9b0c0d commit feea6f6

File tree

11 files changed

+115
-43
lines changed

11 files changed

+115
-43
lines changed

app/code/Magento/Catalog/Test/Fixture/AddAttributeToAttributeSet.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ public function __construct(
3939
}
4040

4141
/**
42-
* @inheritdoc
42+
* {@inheritdoc}
43+
* @param array $data Parameters
44+
* <pre>
45+
* $data = [
46+
* 'attribute_code' => (string) Attribute Code. Required.
47+
* 'attribute_set_id' => (int) Attribute Set ID. Optional. Default: default attribute set.
48+
* 'attribute_group_id' => (int) Attribute Group ID. Optional. Default: default attribute group.
49+
* 'sort_order' => (int) Sort Order. Optional. Default: 0.
50+
* ]
51+
* </pre>
4352
*/
4453
public function apply(array $data = []): ?DataObject
4554
{
@@ -49,7 +58,6 @@ public function apply(array $data = []): ?DataObject
4958
[
5059
'attribute_set_id' => $attributeSetId,
5160
'attribute_group_id' => $attributeGroupId,
52-
'attribute_code' => 'fixture_attribute',
5361
'sort_order' => 0,
5462
],
5563
$data

app/code/Magento/Catalog/Test/Fixture/Attribute.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class Attribute implements RevertibleDataFixtureInterface
3434
'used_in_product_listing' => '0',
3535
'is_visible' => true,
3636
'scope' => 'store',
37-
'attribute_code' => 'fixture_attribute_%uniqid%',
37+
'attribute_code' => 'product_attribute%uniqid%',
3838
'frontend_input' => 'text',
3939
'entity_type_id' => '4',
4040
'is_required' => false,
4141
'options' => [],
4242
'is_user_defined' => true,
43-
'default_frontend_label' => 'Fixture Attribute %uniqid%',
43+
'default_frontend_label' => 'Product Attribute%uniqid%',
4444
'frontend_labels' => [],
4545
'backend_type' => 'varchar',
4646
'is_unique' => '0',
@@ -70,7 +70,8 @@ public function __construct(
7070
}
7171

7272
/**
73-
* @inheritdoc
73+
* {@inheritdoc}
74+
* @param array $data Parameters. Same format as Attribute::DEFAULT_DATA.
7475
*/
7576
public function apply(array $data = []): ?DataObject
7677
{

app/code/Magento/Catalog/Test/Fixture/Category.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Category implements RevertibleDataFixtureInterface
4343
* @var ProcessorInterface
4444
*/
4545
private $dataProcessor;
46+
4647
/**
4748
* @var DataMerger
4849
*/
@@ -63,7 +64,9 @@ public function __construct(
6364
}
6465

6566
/**
66-
* @inheritdoc
67+
* {@inheritdoc}
68+
* @param array $data Parameters. Same format as Category::DEFAULT_DATA. Custom attributes and extension attributes
69+
* can be passed directly in the outer array instead of custom_attributes or extension_attributes.
6770
*/
6871
public function apply(array $data = []): ?DataObject
6972
{

app/code/Magento/Catalog/Test/Fixture/Product.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function __construct(
8080
}
8181

8282
/**
83-
* @inheritdoc
83+
* {@inheritdoc}
84+
* @param array $data Parameters. Same format as Product::DEFAULT_DATA. Custom attributes and extension attributes
85+
* can be passed directly in the outer array instead of custom_attributes or extension_attributes.
8486
*/
8587
public function apply(array $data = []): ?DataObject
8688
{
@@ -115,7 +117,7 @@ public function revert(DataObject $data): void
115117
private function prepareData(array $data): array
116118
{
117119
$data = $this->dataMerger->merge(self::DEFAULT_DATA, $data);
118-
// remove category_links if empty in order for category_ids to processed if exists
120+
// remove category_links if empty in order for category_ids to be processed if exists
119121
if (empty($data['extension_attributes']['category_links'])) {
120122
unset($data['extension_attributes']['category_links']);
121123
}

app/code/Magento/Quote/Test/Fixture/AddProductToCart.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ public function __construct(
3737
}
3838

3939
/**
40-
* @inheritdoc
40+
* {@inheritdoc}
41+
* @param array $data Parameters
42+
* <pre>
43+
* $data = [
44+
* 'cart_id' => (int) Cart ID. Required.
45+
* 'product_id' => (int) Product ID. Required.
46+
* 'qty' => (int) Quantity. Optional. Default: 1.
47+
* ]
48+
* </pre>
4149
*/
4250
public function apply(array $data = []): ?DataObject
4351
{

app/code/Magento/Quote/Test/Fixture/SetBillingAddress.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
class SetBillingAddress implements DataFixtureInterface
1717
{
1818
private const DEFAULT_DATA = [
19-
AddressInterface::KEY_TELEPHONE => 3468676,
20-
AddressInterface::KEY_POSTCODE => 75477,
19+
AddressInterface::KEY_TELEPHONE => 3340000000,
20+
AddressInterface::KEY_POSTCODE => 36104,
2121
AddressInterface::KEY_COUNTRY_ID => 'US',
22-
AddressInterface::KEY_CITY => 'CityM',
23-
AddressInterface::KEY_COMPANY => 'CompanyName',
22+
AddressInterface::KEY_CITY => 'Montgomery',
23+
AddressInterface::KEY_COMPANY => 'Magento',
2424
AddressInterface::KEY_STREET => ['Green str, 67'],
25-
AddressInterface::KEY_LASTNAME => 'Smith',
2625
AddressInterface::KEY_FIRSTNAME => 'John',
26+
AddressInterface::KEY_LASTNAME => 'Doe',
2727
AddressInterface::KEY_REGION_ID => 1,
2828
];
2929

@@ -42,7 +42,14 @@ public function __construct(
4242
}
4343

4444
/**
45-
* @inheritdoc
45+
* {@inheritdoc}
46+
* @param array $data Parameters
47+
* <pre>
48+
* $data = [
49+
* 'cart_id' => (int) Cart ID. Required.
50+
* 'address' => (array) Address Data. Optional. Default: SetBillingAddress::DEFAULT_DATA
51+
* ]
52+
* </pre>
4653
*/
4754
public function apply(array $data = []): ?DataObject
4855
{

app/code/Magento/Quote/Test/Fixture/SetShippingAddress.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
class SetShippingAddress implements DataFixtureInterface
1717
{
1818
private const DEFAULT_DATA = [
19-
AddressInterface::KEY_TELEPHONE => 3468676,
20-
AddressInterface::KEY_POSTCODE => '75477',
19+
AddressInterface::KEY_TELEPHONE => 3340000000,
20+
AddressInterface::KEY_POSTCODE => 36104,
2121
AddressInterface::KEY_COUNTRY_ID => 'US',
22-
AddressInterface::KEY_CITY => 'CityM',
23-
AddressInterface::KEY_COMPANY => 'CompanyName',
22+
AddressInterface::KEY_CITY => 'Montgomery',
23+
AddressInterface::KEY_COMPANY => 'Magento',
2424
AddressInterface::KEY_STREET => ['Green str, 67'],
25-
AddressInterface::KEY_LASTNAME => 'Smith',
25+
AddressInterface::KEY_LASTNAME => 'Doe',
2626
AddressInterface::KEY_FIRSTNAME => 'John',
2727
AddressInterface::KEY_REGION_ID => 1,
2828
];
@@ -39,7 +39,14 @@ public function __construct(
3939
}
4040

4141
/**
42-
* @inheritdoc
42+
* {@inheritdoc}
43+
* @param array $data Parameters
44+
* <pre>
45+
* $data = [
46+
* 'cart_id' => (int) Cart ID. Required.
47+
* 'address' => (array) Address Data. Optional. Default: SetShippingAddress::DEFAULT_DATA
48+
* ]
49+
* </pre>
4350
*/
4451
public function apply(array $data = []): ?DataObject
4552
{

app/code/Magento/Store/Test/Fixture/Group.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ public function __construct(
7070
}
7171

7272
/**
73-
* @inheritdoc
73+
* {@inheritdoc}
74+
* @param array $data Parameters
75+
* <pre>
76+
* $data = [
77+
* 'id' => (int) ID. Optional.
78+
* 'code' => (string) Code. Optional.
79+
* 'name' => (string) Name. Optional.
80+
* 'website_id' => (int) Website ID. Optional. Default: default website.
81+
* 'root_category_id' => (int) Root Category ID. Optional. Default: default root category.
82+
* 'default_store_id' => (int) Default Store ID. Optional.
83+
* ]
84+
* </pre>
7485
*/
7586
public function apply(array $data = []): ?DataObject
7687
{

app/code/Magento/Store/Test/Fixture/Store.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class Store implements RevertibleDataFixtureInterface
2020
private const DEFAULT_DATA = [
2121
'code' => 'test_store_view%uniqid%',
2222
'name' => 'Test Store View%uniqid%',
23-
'sort_order' => '1'
23+
'sort_order' => '0',
24+
'is_active' => '1'
2425
];
2526

2627
/**
@@ -62,7 +63,19 @@ public function __construct(
6263
}
6364

6465
/**
65-
* @inheritdoc
66+
* {@inheritdoc}
67+
* @param array $data Parameters
68+
* <pre>
69+
* $data = [
70+
* 'id' => (int) ID. Optional.
71+
* 'code' => (string) Code. Optional.
72+
* 'name' => (string) Name. Optional.
73+
* 'website_id' => (int) Website ID. Optional. Default: default website.
74+
* 'store_group_id' => (int) Store Group ID. Optional. Default: default store group.
75+
* 'is_active' => (int) Is Active. Optional. Default: 1
76+
* 'sort_order' => (int) Sort Order. Optional. Default: 0
77+
* ]
78+
* </pre>
6679
*/
6780
public function apply(array $data = []): ?DataObject
6881
{
@@ -108,6 +121,7 @@ private function prepareData(array $data): array
108121
} elseif (!isset($data['store_group_id']) && isset($data['website_id'])) {
109122
$data['store_group_id'] = $this->storeManager->getWebsite($data['website_id'])->getDefaultGroupId();
110123
}
124+
$data['group_id'] = $data['store_group_id'];
111125

112126
return $this->dataProcessor->process($this, $data);
113127
}

app/code/Magento/Store/Test/Fixture/Website.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,18 @@ public function __construct(
6262
}
6363

6464
/**
65-
* @inheritdoc
65+
* {@inheritdoc}
66+
* @param array $data Parameters
67+
* <pre>
68+
* $data = [
69+
* 'id' => (int) ID. Optional.
70+
* 'code' => (string) Code. Optional.
71+
* 'name' => (string) Name. Optional.
72+
* 'default_group_id' => (int) Default Group ID. Optional.
73+
* 'is_default' => (int) Is Default. Optional. Default: 0.
74+
* 'sort_order' => (int) Sort Order. Optional. Default: 0.
75+
* ]
76+
* </pre>
6677
*/
6778
public function apply(array $data = []): ?DataObject
6879
{

0 commit comments

Comments
 (0)