Skip to content

Commit 0f64e29

Browse files
authored
Merge pull request #693 from ajithkumar-maragathavel/data-entity-improvements
Data entity document improvement
2 parents 7a21f39 + 657aabb commit 0f64e29

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

docs/data.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The following diagram shows the XML structure of an MFTF data object:
77

88
<!-- {% raw %} -->
99

10+
The MFTF `<data>` entities are stored in `<module_dir>/Test/Mftf/Data/`.
11+
1012
## Supply data to test by reference to a data entity
1113

1214
Test steps requiring `<data>` input in an action, like filling a field with a string, may reference an attribute from a data entity:
@@ -20,6 +22,20 @@ In this example:
2022
* `SimpleSubCategory` is an entity name.
2123
* `name` is a `<data>` key of the entity. The corresponding value will be assigned to `userInput` as a result.
2224

25+
The following is an example of the usage of `<data>` entity in the `Magento/Customer/Test/Mftf/Test/AdminCustomersAllCustomersNavigateMenuTest.xml` test:
26+
27+
```xml
28+
<actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToAllCustomerPage">
29+
<argument name="menuUiId" value="{{AdminMenuCustomers.dataUiId}}"/>
30+
<argument name="submenuUiId" value="{{AdminMenuCustomersAllCustomers.dataUiId}}"/>
31+
</actionGroup>
32+
```
33+
34+
In the above example:
35+
36+
* `AdminMenuCustomers` is an entity name.
37+
* `dataUiId` is a `<data>` key of the entity.
38+
2339
### Environmental data
2440

2541
```xml
@@ -32,6 +48,12 @@ In this example:
3248
* `MAGENTO_ADMIN_USERNAME` is a name of an environment variable.
3349
The corresponding value will be assigned to `userInput` as a result.
3450

51+
The following is an example of the usage of `_ENV` in the `Magento/Braintree/Test/Mftf/ActionGroup/AdminDeleteRoleActionGroup.xml` action group:
52+
53+
```xml
54+
<fillField stepKey="TypeCurrentPassword" selector="{{AdminDeleteRoleSection.current_pass}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/>
55+
```
56+
3557
### Sensitive data
3658

3759
```xml
@@ -47,6 +69,14 @@ In this example:
4769

4870
Learn more in [Credentials][].
4971

72+
The following is an example of the usage of `_CREDS` in the `Magento/Braintree/Test/Mftf/Data/BraintreeData.xml` data entity:
73+
74+
```xml
75+
<entity name="MerchantId" type="merchant_id">
76+
<data key="value">{{_CREDS.magento/braintree_enabled_fraud_merchant_id}}</data>
77+
</entity>
78+
```
79+
5080
## Persist a data entity as a prerequisite of a test {#persist-data}
5181

5282
A test can specify an entity to be persisted (created in the database) so that the test actions could operate on the existing known data.
@@ -63,6 +93,14 @@ In this example:
6393
* `email` is a data key of the entity.
6494
The corresponding value will be assigned to `userInput` as a result.
6595

96+
The following is an example of the usage of the persistant data in `Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml` test:
97+
98+
```xml
99+
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterTheCustomerByEmail">
100+
<argument name="email" value="$$createCustomer.email$$"/>
101+
</actionGroup>
102+
```
103+
66104
<div class="bs-callout bs-callout-info">
67105
As of MFTF 2.3.6, you no longer need to differentiate between scopes (a test, a hook, or a suite) for persisted data when referencing it in tests.
68106
</div>
@@ -107,7 +145,7 @@ userInput="We'll email you an order confirmation with details and tracking info.
107145

108146
## Format
109147

110-
The format of `<data>` is:
148+
The format of the `<data>` entity is:
111149

112150
```xml
113151
<?xml version="1.0" encoding="UTF-8"?>
@@ -135,7 +173,7 @@ The following conventions apply to MFTF `<data>`:
135173

136174
## Example
137175

138-
Example (`.../Catalog/Data/CategoryData.xml` file):
176+
Example (`Magento/Catalog/Test/Mftf/Data/CategoryData.xml` file):
139177

140178
```xml
141179
<?xml version="1.0" encoding="UTF-8"?>
@@ -205,7 +243,7 @@ You can also call data from the xml definition of a `data` tag directly:
205243

206244
Attributes|Type|Use|Description
207245
---|---|---|---
208-
`name`|string|optional|Name of the `<entity>`.
246+
`name`|string|optional|Name of the `<entity>`. Use camel case for entity names.
209247
`type`|string|optional|Node containing the exact name of `<entity>` type. Used later to find specific Persistence Layer Model class. `type` in `<data>` can be whatever the user wants; There are no constraints. It is important when persisting data, depending on the `type` given, as it will try to match a metadata definition with the operation being done. Example: A `myCustomer` entity with `type="customer"`, calling `<createData entity="myCustomer"/>`, will try to find a metadata entry with the following attributes: `<operation dataType="customer" type="create">`.
210248
`deprecated`|string|optional|Used to warn about the future deprecation of the data entity. String will appear in Allure reports and console output at runtime.
211249

@@ -220,6 +258,12 @@ Attributes|Type|Use|Description
220258
`key`|string|optional|Key attribute of data/value pair.
221259
`unique`|enum: `"prefix"`, `"suffix"`|optional|Add suite or test wide unique sequence as "prefix" or "suffix" to the data value if specified.
222260

261+
Example:
262+
263+
```xml
264+
<data key="name" unique="suffix">simpleCategory</data>
265+
```
266+
223267
### var {#var-tag}
224268

225269
`<var>` is an element that can be used to grab a key value from another entity. For example, when creating a customer with the `<createData>` action, the server responds with the auto-incremented ID of that customer. Use `<var>` to access that ID and use it in another data entity.
@@ -231,6 +275,12 @@ Attributes|Type|Use|Description
231275
`entityKey`|string|optional|Key attribute of the referenced entity from which to get a value.
232276
`unique`|--|--|*This attribute hasn't been implemented yet.*
233277

278+
Example:
279+
280+
```xml
281+
<var key="parent_id" entityType="category" entityKey="id" />
282+
```
283+
234284
### requiredEntity {#requiredentity-tag}
235285

236286
`<requiredEntity>` is an element that specifies the parent/child relationship between complex types.

0 commit comments

Comments
 (0)