You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
See the `block` node attributes details in the following table:
4
+
5
+
|`block` attribute | Description | Is required|Values| Example|
6
+
|---|---|---|---|---|
7
+
|`name`| Name of the block| Required|Unique in the page. The method to get the block class instance is generated using this value.|`widgetGrid`|
8
+
|`class`| Full name of the block class |Required| Class name |`Magento\Widget\Test\Block\Adminhtml\Widget\WidgetGrid`|
9
+
|`locator`| CSS selector or XPath locator of the block|Required|[CSS Selectors](http://www.w3.org/TR/selectors/), <ahref="http://www.w3.org/TR/xpath-31/">XPath</a>|CSS: `#widgetInstanceGrid`, XPath: `//*[@id="widgetInstanceGrid"]`|
10
+
|`strategy`|Selector strategy| Required|`css selector` or `xpath`|`css selector`|
The repository stores pre-defined data for the fixture.
27
19
It contains only data sets that are used in the test along with the associated field data.
@@ -30,9 +22,9 @@ Reference to the repository is placed in the fixture XML file in attribute named
30
22
31
23
In this topic you will learn how to create, use, and merge a repository.
32
24
33
-
<h2id="mtf_repository_create">Create a repository for the entire fixture</h2>
25
+
## Create a repository for the entire fixture {#mtf_repository_create}
34
26
35
-
Let's create a repository for the Widget fixture `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Fixture/Widget.xml`.
27
+
Let's create a repository for the Widget fixture `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Fixture/Widget.xml`.
36
28
37
29
<ahref="{{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html">More details about fixtures</a>.
38
30
@@ -81,11 +73,11 @@ Assume that we have the following fixture:
81
73
82
74
{% endhighlight %}
83
75
84
-
The `repository_class="Magento\Widget\Test\Repository\Widget"` attribute tells us that this fixture uses data from the `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml` repository.
76
+
The `repository_class="Magento\Widget\Test\Repository\Widget"` attribute tells us that this fixture uses data from the `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml` repository.
85
77
86
78
In this section we will show the logic of how to create this repository.
87
79
88
-
Also `layout` and `widgetOptions` fields use `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/LayoutUpdates.xml` and `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetOptions.xml` repositories respectively.
80
+
Also `layout` and `widgetOptions` fields use `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/LayoutUpdates.xml` and `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetOptions.xml` repositories respectively.
89
81
90
82
<ahref="#mtf_repository_create-field"> Learn how to create repository for the fixture field</a>.
91
83
@@ -142,7 +134,7 @@ To create a new CMS page link the user must enter data of all required fields. T
142
134
143
135
This simple code contains a bit more complex logic, where <ahref="#mtf_repository_create-field">the repository is applied to the fixture field</a>. Just to remind you, how this field is represented in the fixture: `<field name="widgetOptions" source="Magento\Widget\Test\Fixture\Widget\WidgetOptions" repository="Magento\Widget\Test\Repository\Widget\WidgetOptions" group="widget_options" />`.
144
136
145
-
In brief, we reference another repository `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetOptions.xml`, and a <ahref="{{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html#mtf_fixture_source">source</a> that is `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Fixture/Widget/WidgetOptions.php`.
137
+
In brief, we reference another repository `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetOptions.xml`, and a <ahref="{{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html#mtf_fixture_source">source</a> that is `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Fixture/Widget/WidgetOptions.php`.
146
138
147
139
The `WidgetOptions.xml` repository includes `cmsPageLink` dataset:
148
140
@@ -158,11 +150,11 @@ The `WidgetOptions.xml` repository includes `cmsPageLink` dataset:
158
150
159
151
{% endhighlight xml %}
160
152
161
-
The source understands the `entities` field as an instruction to create a CMS Page using `<dataset name="default">` from the `magento2/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsPage.xml` repository.
153
+
The source understands the `entities` field as an instruction to create a CMS Page using `<dataset name="default">` from the `<magento2>/dev/tests/functional/tests/app/Magento/Cms/Test/Repository/CmsPage.xml` repository.
162
154
163
155
<h4id="mtf_repo_widgetxml">Widget.xml</h4>
164
156
165
-
Now we can create a repository XML file `Widget.xml`. In our case the file should be placed in `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository`. The full name must be specified in the `repository_class` attribute of the fixture: `repository_class="Magento\Widget\Test\Repository\Widget"`.
157
+
Now we can create a repository XML file `Widget.xml`. In our case the file should be placed in `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository`. The full name must be specified in the `repository_class` attribute of the fixture: `repository_class="Magento\Widget\Test\Repository\Widget"`.
166
158
167
159
See the entire repository sample so far:
168
160
@@ -223,7 +215,7 @@ See the entire repository sample so far:
@@ -250,11 +242,11 @@ Let's look at the repository structure.
250
242
251
243
The `default` data set is used in the test when the repository hasn't been specified in the test, although you can explicitly specify `default`. If repository name in the test is `cms_page_link`, then fields will be filled with data from `<dataset name="cms_page_link">`.
252
244
253
-
<h2id="mtf_repository_create-field"> Create a repository for the fixture field</h2>
245
+
## Create a repository for the fixture field {#mtf_repository_create-field}
254
246
255
247
In the preceding section, the Widget fixture code contains fields with the links for repositories. Let's consider the field `layout` with `repository="Magento\Widget\Test\Repository\Widget\LayoutUpdates`.
256
248
257
-
The repository value is a reference to the repository XML file. Therefore, we should create `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/LayoutUpdates.xml`. The XML structure of this repository is the same as of <ahref="#mtf_repository_create">repository for the entire fixture</a>.
249
+
The repository value is a reference to the repository XML file. Therefore, we should create `<magento2>/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/LayoutUpdates.xml`. The XML structure of this repository is the same as of <ahref="#mtf_repository_create">repository for the entire fixture</a>.
258
250
259
251
Assume that we want to provide data for the Layout Update block for the following cases shown on the screenshots (name of datasets have orange font, fields defined in repository are highlighted in orange).
260
252
@@ -323,11 +315,11 @@ The repository code for these cases follows:
The configuration repository stores predefined data sets for Magento configuration settings. It is the repository for the <ahref="https://github.com/magento/magento2/tree/master/app/code/Magento/Config">Magento_Config module</a> and is named `ConfigData.xml`.
329
321
330
-
Let's see the following example of configuration settings for <ahref="https://github.com/magento/magento2/tree/develop/app/code/Magento/Authorizenet">Authorize.Net module</a> `magento2/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml`.
322
+
Let's see the following example of configuration settings for <ahref="https://github.com/magento/magento2/tree/develop/app/code/Magento/Authorizenet">Authorize.Net module</a> `<magento2>/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Repository/ConfigData.xml`.
331
323
332
324
{% highlight xml %}
333
325
@@ -425,7 +417,7 @@ Let's see the `authorizenet` data set in action. Fields defined in repository ar
425
417
426
418

The MTF enables you to split data sets among different modules. The configuration repository is a good example.
431
423
@@ -435,27 +427,27 @@ Modules that require configuration adjustment store `ConfigData.xml` in their `R
435
427
436
428
As you can see, the `ConfigData.xml` of the `Authorizenet` module and the `ConfigData.xml` of <ahref="https://github.com/magento/magento2/tree/master/app/code/Magento/Backend">the `Magento_Backend` module</a> have the same reference to the repository class; that is `Magento\Config\Test\Repository\ConfigData`.
437
429
438
-
`ConfigData.php` will be generated in `magento2/dev/tests/functional/generated/Magento/Config/Test/Repository`. This PHP repository will contain repository data sets from all Magento modules that have a `ConfigData.xml` repository.
430
+
`ConfigData.php` will be generated in `<magento2>/dev/tests/functional/generated/Magento/Config/Test/Repository`. This PHP repository will contain repository data sets from all Magento modules that have a `ConfigData.xml` repository.
439
431
440
-
To run the generator, enter the following command:
432
+
To run the generator, enter the following command in your terminal:
The preceding is an example of repository merging. Using the approach from the example you can merge repositories for any other fixture, not `Config` only.
445
437
446
-
<h2id="mtf_repository_credent_iso">Credentials and %isolation% in repository</h2>
438
+
## Credentials and `%isolation%` in repository {#mtf_repository_credent_iso}
447
439
448
440
Credentials are stored in XML file specified in `phpunit.xml`.
449
441
450
-
You can find a template for credentials in <ahref="https://github.com/magento/magento2/blob/master/dev/tests/functional/credentials.xml.dist"><code>magento2/dev/tests/functional/credentials.xml.dist</code></a>.
442
+
You can find a template for credentials in <ahref="https://github.com/magento/magento2/blob/master/dev/tests/functional/credentials.xml.dist"><code><magento2>/dev/tests/functional/credentials.xml.dist</code></a>.
451
443
452
444
Credentials always should stay invisible for security reasons. The MTF implicitly pastes credentials during the test run only.
453
445
There are two ways to paste credentials:
454
446
455
447
-**Using path**. If a field in a repository has a `name` that matches field `path` in `credentials.xml`, then the value of this field will be substituted for the value from `credential.xml` during the test.
456
448
-**Using placeholder**. If a field in a repository has value wrapped in `% %` that matches the value of the `replace` field attribute in `credentials.xml`, then the value of this field will be substituted for the value from `credential.xml` during the test.
457
449
458
-
<h3id="mtf_repo_credent_path">Example with substitution by <code>path</code></h3>
450
+
### Example with substitution by <code>path</code> {#mtf_repo_credent_path}
459
451
460
452
Assume, that you have the following credentials in `credentials.xml`.
461
453
@@ -501,7 +493,7 @@ In the repository these fields can be defined as:
501
493
502
494
During the test run these fields are filled with values from `credentials.xml`.
503
495
504
-
<h3id="mtf_repo_credent_replace">Example with replacement by <code>replace</code></h3>
496
+
### Example with replacement by <code>replace</code> {#mtf_repo_credent_replace}
505
497
506
498
For example, you have the following credentials in `credentials.xml`:
507
499
@@ -540,7 +532,7 @@ Then you should define repository fields as the following:
540
532
541
533
When the test is run, credentials from `credentials.xml` are transfered to the defined fields.
You can use `%isolation%` placeholder in repository fields where you want to put a random value. It is useful when you need a unique value, for example `sku`, that has to be unique each test cycle.
0 commit comments