Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 23749aa

Browse files
author
Shevtsov, Dmitry(dshevtsov)
committed
Merge pull request #4 from Magento/pubs2411-block
Pubs2411 Block and Page
2 parents d957514 + ffce775 commit 23749aa

28 files changed

+837
-203
lines changed

_includes/mtf/block_attributes.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div markdown="1">
2+
3+
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/), <a href="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`|
11+
12+
</div>

_includes/mtf/page-generator.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<p>To apply all changes you've made to the page (XML file), run the page generator.</p>
2+
<pre><code>php &lt;magento2&gt;/dev/tests/functional/utils/page.php</code></pre>
3+
<p>The page will be updated in the <code>&lt;magento2&gt;/dev/tests/functional/generated</code> directory.</p>

_plugins/remote_markdown.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# "THE BEER-WARE LICENSE" (Revision 42):
2+
# <[email protected]> wrote this file. As long as you retain this
3+
# notice you can do whatever you want with this stuff. If we meet some day, and
4+
# you think this stuff is worth it, you can buy me a beer in return.
5+
# Robin Hahling
6+
7+
require 'net/http'
8+
9+
module Jekyll
10+
# Remotely fetch a markdown file.
11+
class RemoteMarkdownTag < Liquid::Tag
12+
def initialize(tag_name, text, tokens)
13+
super
14+
15+
text.strip!
16+
check_protocol(text)
17+
uri = URI(text)
18+
19+
check_extension(uri.path)
20+
21+
res = Net::HTTP.get_response(uri)
22+
fail 'resource unavailable' unless res.is_a?(Net::HTTPSuccess)
23+
24+
@content = res.body.force_encoding("UTF-8")
25+
end
26+
27+
def render(_context)
28+
@content
29+
end
30+
31+
private
32+
33+
def check_protocol(text)
34+
error_message = "remote_markdown: invalid URI given #{text}"
35+
fail error_message unless text =~ URI.regexp(%w(http https ftp ftps))
36+
end
37+
38+
def check_extension(path)
39+
mdexts = %w(.markdown .mkdown .mkdn .mkd .md .xml)
40+
error_message = "remote_markdown: URI file extension not in #{mdexts}"
41+
fail error_message unless mdexts.include?(File.extname(path))
42+
end
43+
end
44+
end
45+
46+
Liquid::Template.register_tag('remote_markdown', Jekyll::RemoteMarkdownTag)
45.7 KB
Loading
13.1 KB
Loading

common/images/mtf_block_login_dir.png

6.77 KB
Loading

common/images/mtf_block_login_ui.png

122 KB
Loading
24.7 KB
Loading
14.4 KB
Loading
39.2 KB
Loading
29.3 KB
Loading
52.7 KB
Loading

common/images/mtf_block_tab_struc.png

6.94 KB
Loading

common/images/mtf_block_tabs_ui.png

27.6 KB
Loading
2.85 KB
Loading

guides/v2.0/mtf/mtf_changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ redirect_from: /guides/v1.0/mtf/mtf_changelog.html
1212

1313
Check current state of the Magento Testing Framework, history of changes and list of releases on [GitHub][].
1414

15-
[GitHub]: https://github.com/magento/mtf/blob/develop/CHANGELOG.md
15+
[GitHub]: https://github.com/magento/mtf/blob/develop/CHANGELOG.md

guides/v2.0/mtf/mtf_entities/mtf_block.md

Lines changed: 468 additions & 6 deletions
Large diffs are not rendered by default.

guides/v2.0/mtf/mtf_entities/mtf_fixture-repo.md

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,13 @@ menu_title: Fixture Repository
77
menu_order: 2
88
github_link: mtf/mtf_entities/mtf_fixture-repo.md
99
---
10-
<h3>Contents</h3>
1110

12-
- <a href="#mtf_repository_overview">Repository overview</a>
11+
<h2>Fixture repository</h2>
1312

14-
- <a href="#mtf_repository_create">Create a repository for the entire fixture</a>
13+
* TOC
14+
{:toc}
1515

16-
- <a href="#mtf_repository_create-field"> Create a repository for the fixture field</a>
17-
18-
- <a href="#mtf_repository_config">Configuration repository</a>
19-
20-
- <a href="#mtf_repository_merge">Merging repositories</a>
21-
22-
- <a href="#mtf_repository_credent_iso">Credentials and <code>%isolation%</code> in repository</a>
23-
24-
<h2 id="mtf_repository_overview">Repository overview</h2>
16+
## Repository overview {#mtf_repository_overview}
2517

2618
The repository stores pre-defined data for the fixture.
2719
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
3022

3123
In this topic you will learn how to create, use, and merge a repository.
3224

33-
<h2 id="mtf_repository_create">Create a repository for the entire fixture</h2>
25+
## Create a repository for the entire fixture {#mtf_repository_create}
3426

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`.
3628

3729
<a href="{{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html">More details about fixtures</a>.
3830

@@ -81,11 +73,11 @@ Assume that we have the following fixture:
8173

8274
{% endhighlight %}
8375

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.
8577

8678
In this section we will show the logic of how to create this repository.
8779

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.
8981

9082
<a href="#mtf_repository_create-field"> Learn how to create repository for the fixture field</a>.
9183

@@ -142,7 +134,7 @@ To create a new CMS page link the user must enter data of all required fields. T
142134

143135
This simple code contains a bit more complex logic, where <a href="#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" />`.
144136

145-
In brief, we reference another repository `magento2/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget/WidgetOptions.xml`, and a <a href="{{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 <a href="{{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`.
146138

147139
The `WidgetOptions.xml` repository includes `cmsPageLink` dataset:
148140

@@ -158,11 +150,11 @@ The `WidgetOptions.xml` repository includes `cmsPageLink` dataset:
158150

159151
{% endhighlight xml %}
160152

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.
162154

163155
<h4 id="mtf_repo_widgetxml">Widget.xml</h4>
164156

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"`.
166158

167159
See the entire repository sample so far:
168160

@@ -223,7 +215,7 @@ See the entire repository sample so far:
223215

224216
{% endhighlight %}
225217

226-
<h3 id="mtf_repository_structure">Repository structure</h3>
218+
### Repository structure {#mtf_repository_structure}
227219

228220
Let's look at the repository structure.
229221

@@ -250,11 +242,11 @@ Let's look at the repository structure.
250242

251243
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">`.
252244

253-
<h2 id="mtf_repository_create-field"> Create a repository for the fixture field</h2>
245+
## Create a repository for the fixture field {#mtf_repository_create-field}
254246

255247
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`.
256248

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 <a href="#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 <a href="#mtf_repository_create">repository for the entire fixture</a>.
258250

259251
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).
260252

@@ -323,11 +315,11 @@ The repository code for these cases follows:
323315

324316
{% endhighlight %}
325317

326-
<h2 id="mtf_repository_config">Configuration repository</h2>
318+
## Configuration repository {#mtf_repository_config}
327319

328320
The configuration repository stores predefined data sets for Magento configuration settings. It is the repository for the <a href="https://github.com/magento/magento2/tree/master/app/code/Magento/Config">Magento_Config module</a> and is named `ConfigData.xml`.
329321

330-
Let's see the following example of configuration settings for <a href="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 <a href="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`.
331323

332324
{% highlight xml %}
333325

@@ -425,7 +417,7 @@ Let's see the `authorizenet` data set in action. Fields defined in repository ar
425417

426418
![authorizenet dataset view on GUI]({{site.baseurl}}common/images/mtf_repo_config_ex.png)
427419

428-
<h2 id="mtf_repository_merge">Merging repositories</h2>
420+
## Merging repositories {#mtf_repository_merge}
429421

430422
The MTF enables you to split data sets among different modules. The configuration repository is a good example.
431423

@@ -435,27 +427,27 @@ Modules that require configuration adjustment store `ConfigData.xml` in their `R
435427

436428
As you can see, the `ConfigData.xml` of the `Authorizenet` module and the `ConfigData.xml` of <a href="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`.
437429

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.
439431

440-
To run the generator, enter the following command:
432+
To run the generator, enter the following command in your terminal:
441433

442-
php magento2/dev/tests/functional/utils/generate.php
434+
php <magento2>/dev/tests/functional/utils/generate.php
443435

444436
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.
445437

446-
<h2 id="mtf_repository_credent_iso">Credentials and %isolation% in repository</h2>
438+
## Credentials and `%isolation%` in repository {#mtf_repository_credent_iso}
447439

448440
Credentials are stored in XML file specified in `phpunit.xml`.
449441

450-
You can find a template for credentials in <a href="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 <a href="https://github.com/magento/magento2/blob/master/dev/tests/functional/credentials.xml.dist"><code>&lt;magento2&gt;/dev/tests/functional/credentials.xml.dist</code></a>.
451443

452444
Credentials always should stay invisible for security reasons. The MTF implicitly pastes credentials during the test run only.
453445
There are two ways to paste credentials:
454446

455447
- **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.
456448
- **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.
457449

458-
<h3 id="mtf_repo_credent_path">Example with substitution by <code>path</code></h3>
450+
### Example with substitution by <code>path</code> {#mtf_repo_credent_path}
459451

460452
Assume, that you have the following credentials in `credentials.xml`.
461453

@@ -501,7 +493,7 @@ In the repository these fields can be defined as:
501493

502494
During the test run these fields are filled with values from `credentials.xml`.
503495

504-
<h3 id="mtf_repo_credent_replace">Example with replacement by <code>replace</code></h3>
496+
### Example with replacement by <code>replace</code> {#mtf_repo_credent_replace}
505497

506498
For example, you have the following credentials in `credentials.xml`:
507499

@@ -540,7 +532,7 @@ Then you should define repository fields as the following:
540532

541533
When the test is run, credentials from `credentials.xml` are transfered to the defined fields.
542534

543-
<h3 id="mtf_repo_isolation"><code>%isolation%</code> placeholder</h3>
535+
### `%isolation%` placeholder {#mtf_repo_isolation}
544536

545537
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.
546538

0 commit comments

Comments
 (0)