Skip to content

Commit 0f1af99

Browse files
author
Yaroslav Onischenko
authored
Merge pull request #455 from magento-qmt/PR
[Mavericks] Extend functional tests
2 parents 152309b + 7cfbc9f commit 0f1af99

40 files changed

+904
-174
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Mtf\Util\Command\Cli;
8+
9+
use Magento\Mtf\Util\Command\Cli;
10+
11+
/**
12+
* Setup Magento for tests executions.
13+
*/
14+
class Setup extends Cli
15+
{
16+
/**
17+
* Parameter for uninstall Magento command.
18+
*/
19+
const PARAM_SETUP_UNINSTALL = 'setup:uninstall';
20+
21+
/**
22+
* Options for uninstall Magento command.
23+
*
24+
* @var array
25+
*/
26+
private $options = ['-n'];
27+
28+
/**
29+
* Uninstall Magento.
30+
*
31+
* @return void
32+
*/
33+
public function uninstall()
34+
{
35+
parent::execute(Setup::PARAM_SETUP_UNINSTALL, $this->options);
36+
}
37+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Action/Attribute.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\Tab;
8+
9+
use Magento\Mtf\Client\Element\SimpleElement;
10+
use Magento\Mtf\Client\Locator;
11+
use Magento\Backend\Test\Block\Widget\Tab;
12+
13+
/**
14+
* Tab on Product update attributes Form.
15+
*/
16+
class UpdateAttributeTab extends Tab
17+
{
18+
/**
19+
* Change checkbox.
20+
*
21+
* @var string
22+
*/
23+
private $changeCheckbox = [
24+
'selector' => './/./ancestor::div[contains(@class,"control")]'
25+
. '//input[@data-role="toggle-editability-all" or contains(@id, "toggle_")]',
26+
'strategy' => Locator::SELECTOR_XPATH,
27+
'input' => 'checkbox',
28+
'value' => 'Yes',
29+
];
30+
31+
/**
32+
* Fill data into fields in the container.
33+
*
34+
* @param array $fields
35+
* @param SimpleElement|null $contextElement
36+
* @return $this
37+
*/
38+
public function setFieldsData(array $fields, SimpleElement $contextElement = null)
39+
{
40+
$context = ($contextElement === null) ? $this->_rootElement : $contextElement;
41+
$mapping = $this->dataMapping($fields);
42+
foreach ($mapping as $field) {
43+
$this->_fill([$this->changeCheckbox], $context->find($field['selector'], $field['strategy']));
44+
$this->_fill([$field], $context);
45+
}
46+
47+
return $this;
48+
}
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action;
8+
9+
use Magento\Backend\Test\Block\Widget\FormTabs;
10+
11+
/**
12+
* Product update Attributes Form.
13+
*/
14+
class UpdateAttributeForm extends FormTabs
15+
{
16+
//
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" ?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tabs>
9+
<product-details>
10+
<class>Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\Tab\UpdateAttributeTab</class>
11+
<selector>#attributes_update_tabs_attributes</selector>
12+
<fields>
13+
<price>
14+
<selector>#price</selector>
15+
</price>
16+
</fields>
17+
</product-details>
18+
<advanced-inventory>
19+
<class>Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\Tab\UpdateAttributeTab</class>
20+
<selector>#attributes_update_tabs_inventory</selector>
21+
<fields>
22+
<stock_data>
23+
<selector>#inventory_stock_availability</selector>
24+
<input>select</input>
25+
</stock_data>
26+
</fields>
27+
</advanced-inventory>
28+
</tabs>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Catalog\Test\Block\Adminhtml\Product;
88

99
use Magento\Ui\Test\Block\Adminhtml\DataGrid;
10+
use Magento\Mtf\Fixture\FixtureInterface;
1011

1112
/**
1213
* Backend catalog product grid.
@@ -72,12 +73,17 @@ class Grid extends DataGrid
7273
/**
7374
* Update attributes for selected items.
7475
*
75-
* @param array $items [optional]
76+
* @param array $items
7677
* @return void
7778
*/
7879
public function updateAttributes(array $items = [])
7980
{
80-
$this->massaction($items, 'Update attributes');
81+
$products = [];
82+
/** @var FixtureInterface $product */
83+
foreach ($items as $product) {
84+
$products[] = ["sku" => $product->getSku()];
85+
}
86+
$this->massaction($products, 'Update attributes');
8187
}
8288

8389
/**

dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertMassProductUpdateSuccessMessage.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ class AssertMassProductUpdateSuccessMessage extends AbstractConstraint
2323
* Assert that after mass update successful message appears.
2424
*
2525
* @param CatalogProductIndex $productGrid
26-
* @param array $products
26+
* @param int $productsCount
2727
* @return void
2828
*/
29-
public function processAssert(CatalogProductIndex $productGrid, $products = [])
29+
public function processAssert(CatalogProductIndex $productGrid, $productsCount)
3030
{
31-
$countProducts = count($products) ? count($products) : 1;
32-
$expectedMessage = sprintf(self::SUCCESS_MESSAGE, $countProducts);
31+
$expectedMessage = sprintf(self::SUCCESS_MESSAGE, $productsCount);
3332
$actualMessage = $productGrid->getMessagesBlock()->getSuccessMessage();
3433
\PHPUnit_Framework_Assert::assertEquals(
3534
$expectedMessage,
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Constraint;
8+
9+
use Magento\Catalog\Test\Page\Product\CatalogProductView;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
13+
/**
14+
* Assert that all products are in stock.
15+
*/
16+
class AssertProductsInStock extends AbstractConstraint
17+
{
18+
/**
19+
* Assert that In Stock status is displayed for products.
20+
*
21+
* @param CatalogProductView $catalogProductView
22+
* @param BrowserInterface $browser
23+
* @param AssertProductInStock $assertProductInStock
24+
* @param array $products
25+
* @return void
26+
*/
27+
public function processAssert(
28+
CatalogProductView $catalogProductView,
29+
BrowserInterface $browser,
30+
AssertProductInStock $assertProductInStock,
31+
array $products
32+
) {
33+
foreach ($products as $product) {
34+
$assertProductInStock->processAssert($catalogProductView, $browser, $product);
35+
}
36+
}
37+
38+
/**
39+
* Returns a string representation of the object.
40+
*
41+
* @return string
42+
*/
43+
public function toString()
44+
{
45+
return 'In stock control is visible for each product.';
46+
}
47+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductActionAttributeEdit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
99
<page name="CatalogProductActionAttributeEdit" area="Adminhtml" mca="catalog/product_action_attribute/edit" module="Magento_Catalog">
10-
<block name="attributesBlockForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\Attribute" locator="body" strategy="css selector" />
10+
<block name="attributesBlockForm" class="Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\UpdateAttributeForm" locator="body" strategy="css selector" />
1111
<block name="formPageActions" class="Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Action\FormPageActions" locator=".page-main-actions" strategy="css selector" />
1212
</page>
1313
</config>

0 commit comments

Comments
 (0)