Skip to content

Commit 52b2e78

Browse files
author
Dmytro Aponasenko
committed
Merge pull request #39 from magento-qmt/develop
[Mavericks] Create acceptance functional tests plan and re-factor end-to-end tests
2 parents 4197c31 + ac3411e commit 52b2e78

File tree

259 files changed

+2708
-2452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+2708
-2452
lines changed

dev/tests/functional/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
session_start();
88
defined('MTF_BOOT_FILE') || define('MTF_BOOT_FILE', __FILE__);
9+
defined('MTF_BP') || define('MTF_BP', str_replace('\\', '/', (__DIR__)));
910
require_once __DIR__ . '/../../../app/bootstrap.php';
1011
restore_error_handler();
1112
require_once __DIR__ . '/vendor/autoload.php';

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc11",
3+
"magento/mtf": "1.0.0-rc12",
44
"php": ">=5.4.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SelectstoreElement.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,26 @@
1010
use Mtf\Client\Element\Locator;
1111

1212
/**
13-
* Class SelectstoreElement
14-
* Typified element class for option group selectors
13+
* Typified element class for option group selectors.
1514
*/
1615
class SelectstoreElement extends SelectElement
1716
{
1817
/**
19-
* Store option group selector
18+
* Store option group selector.
2019
*
2120
* @var string
2221
*/
2322
protected $storeGroup = 'optgroup[option[contains(.,"%s")]]';
2423

2524
/**
26-
* Website option group selector
25+
* Website option group selector.
2726
*
2827
* @var string
2928
*/
3029
protected $website = 'optgroup[following-sibling::optgroup[option[contains(.,"%s")]]]';
3130

3231
/**
33-
* Get the value of form element
32+
* Get the value of form element.
3433
*
3534
* @return string
3635
*/
@@ -49,22 +48,28 @@ public function getValue()
4948
}
5049

5150
/**
52-
* Select value in dropdown which has option groups
51+
* Select value in dropdown which has option groups.
5352
*
5453
* @param string $value
5554
* @throws \Exception
5655
* @return void
5756
*/
5857
public function setValue($value)
5958
{
60-
$group = explode('/', $value);
61-
$optionLocator = './/optgroup[contains(@label,"'
62-
. $group[0] . '")]/following-sibling::optgroup[contains(@label,"'
63-
. $group[1] . '")]/option[contains(text(), "'
64-
. $group[2] . '")]';
59+
$pieces = explode('/', $value);
60+
61+
if (1 == count($pieces)) {
62+
$optionLocator = './/option[contains(text(),"' . $pieces[0] . '")]';
63+
} else {
64+
$optionLocator = './/optgroup[contains(@label,"'
65+
. $pieces[0] . '")]/following-sibling::optgroup[contains(@label,"'
66+
. $pieces[1] . '")]/option[contains(text(), "'
67+
. $pieces[2] . '")]';
68+
}
69+
6570
$option = $this->_context->find($optionLocator, Locator::SELECTOR_XPATH);
6671
if (!$option->isVisible()) {
67-
throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.');
72+
throw new \Exception('[' . implode('/', $pieces) . '] option is not visible in store switcher.');
6873
}
6974
$option->click();
7075
}

dev/tests/functional/lib/Mtf/Client/Driver/Selenium/Element/SuggestElement.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ class SuggestElement extends Element
4141
*/
4242
protected $resultItem = './/ul/li/a[text()="%s"]';
4343

44+
/**
45+
* Suggest state loader
46+
*
47+
* @var string
48+
*/
49+
protected $suggestStateLoader = '.mage-suggest-state-loading';
50+
4451
/**
4552
* Set value
4653
*
@@ -52,9 +59,16 @@ public function setValue($value)
5259
$this->_eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
5360

5461
$this->clear();
55-
$this->find($this->suggest)->_getWrappedElement()->value($value);
56-
$this->waitResult();
57-
$this->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH)->click();
62+
foreach (str_split($value) as $symbol) {
63+
$this->find($this->suggest)->click();
64+
$this->_driver->keys($symbol);
65+
$this->waitResult();
66+
$searchedItem = $this->find(sprintf($this->resultItem, $value), Locator::SELECTOR_XPATH);
67+
if ($searchedItem->isVisible()) {
68+
$searchedItem->click();
69+
break;
70+
}
71+
}
5872
}
5973

6074
/**
@@ -77,11 +91,12 @@ protected function clear()
7791
*/
7892
public function waitResult()
7993
{
80-
$browser = $this;
81-
$selector = $this->searchResult;
94+
$browser = clone $this;
95+
$selector = $this->suggestStateLoader;
8296
$browser->waitUntil(
8397
function () use ($browser, $selector) {
84-
return $browser->find($selector)->isVisible() ? true : null;
98+
$element = $browser->find($selector);
99+
return $element->isVisible() == false ? true : null;
85100
}
86101
);
87102
}

dev/tests/functional/lib/Mtf/ObjectManagerFactory.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ class ObjectManagerFactory
4242
*/
4343
public function create(array $sharedInstances = [])
4444
{
45-
if (!defined('MTF_BP')) {
46-
$basePath = str_replace('\\', '/', dirname(dirname(__DIR__)));
47-
define('MTF_BP', $basePath);
48-
}
4945
if (!defined('MTF_TESTS_PATH')) {
5046
define('MTF_TESTS_PATH', MTF_BP . '/tests/app/');
5147
}

dev/tests/functional/phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
<env name="server_config_path" value="config/server.yml.dist" />
3737
<env name="isolation_config_path" value="config/isolation.yml.dist" />
3838
<env name="handlers_config_path" value="config/handler.yml.dist" />
39-
<env name="configuration:Mtf/TestSuite/InjectableTests" value="basic" />
39+
<env name="testsuite_rule" value="basic" />
40+
<env name="testsuite_rule_path" value="Mtf/TestSuite/InjectableTests" />
4041
<env name="log_directory" value="var/log" />
4142
<env name="events_preset" value="base" />
4243
<env name="module_whitelist" value="Magento_Install" />

dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Product/ProductForm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-->
88
<tabs>
99
<product-details>
10-
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\ProductTab</class>
10+
<class>\Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\ProductDetails</class>
1111
<selector>#product_info_tabs_product-details</selector>
1212
<strategy>css selector</strategy>
1313
<wrapper>product</wrapper>

dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleInCategory.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
namespace Magento\Bundle\Test\Constraint;
88

99
use Magento\Bundle\Test\Fixture\BundleProduct;
10-
use Magento\Catalog\Test\Fixture\CatalogCategory;
10+
use Magento\Catalog\Test\Fixture\Category;
1111
use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
1212
use Magento\Cms\Test\Page\CmsIndex;
1313
use Mtf\Constraint\AbstractConstraint;
1414

1515
/**
16-
* Class AssertProductInCategory
16+
* Check bundle product on the category page.
1717
*/
1818
class AssertBundleInCategory extends AbstractConstraint
1919
{
@@ -22,19 +22,19 @@ class AssertBundleInCategory extends AbstractConstraint
2222
/* end tags */
2323

2424
/**
25-
* Check bundle product on the category page
25+
* Check bundle product on the category page.
2626
*
2727
* @param CatalogCategoryView $catalogCategoryView
2828
* @param CmsIndex $cmsIndex
2929
* @param BundleProduct $product
30-
* @param CatalogCategory $category
30+
* @param Category $category
3131
* @return void
3232
*/
3333
public function processAssert(
3434
CatalogCategoryView $catalogCategoryView,
3535
CmsIndex $cmsIndex,
3636
BundleProduct $product,
37-
CatalogCategory $category
37+
Category $category
3838
) {
3939
//Open category view page
4040
$cmsIndex->open();
@@ -45,7 +45,7 @@ public function processAssert(
4545
}
4646

4747
/**
48-
* Verify product price on category view page
48+
* Verify product price on category view page.
4949
*
5050
* @param BundleProduct $bundle
5151
* @param CatalogCategoryView $catalogCategoryView
@@ -57,9 +57,13 @@ protected function assertPrice(BundleProduct $bundle, CatalogCategoryView $catal
5757
//Price from/to verification
5858
$priceBlock = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($bundle->getName());
5959

60-
$priceLow = ($bundle->getPriceView() == 'Price Range')
61-
? $priceBlock->getPriceFrom()
62-
: $priceBlock->getRegularPrice();
60+
if ($bundle->hasData('special_price') || $bundle->hasData('group_price')) {
61+
$priceLow = $priceBlock->getFinalPrice();
62+
} else {
63+
$priceLow = ($bundle->getPriceView() == 'Price Range')
64+
? $priceBlock->getPriceFrom()
65+
: $priceBlock->getRegularPrice();
66+
}
6367

6468
\PHPUnit_Framework_Assert::assertEquals(
6569
$priceData['price_from'],
@@ -76,7 +80,7 @@ protected function assertPrice(BundleProduct $bundle, CatalogCategoryView $catal
7680
}
7781

7882
/**
79-
* Text of Visible in category assert
83+
* Text of Visible in category assert.
8084
*
8185
* @return string
8286
*/

dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundlePriceView.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Mtf\Constraint\AbstractConstraint;
1313

1414
/**
15-
* Class AssertBundlePriceView
15+
* Check displayed price view for bundle product on product page.
1616
*/
1717
class AssertBundlePriceView extends AbstractConstraint
1818
{
@@ -41,7 +41,7 @@ public function processAssert(
4141
}
4242

4343
/**
44-
* Assert prices on the product view Page
44+
* Assert prices on the product view Page.
4545
*
4646
* @param BundleProduct $product
4747
* @param CatalogProductView $catalogProductView
@@ -50,19 +50,22 @@ public function processAssert(
5050
protected function assertPrice(BundleProduct $product, CatalogProductView $catalogProductView)
5151
{
5252
$priceData = $product->getDataFieldConfig('price')['source']->getPreset();
53+
$priceView = $product->getPriceView();
5354
$priceBlock = $catalogProductView->getViewBlock()->getPriceBlock();
5455

55-
$priceLow = ($product->getPriceView() == 'Price Range')
56-
? $priceBlock->getPriceFrom()
57-
: $priceBlock->getRegularPrice();
56+
if ($product->hasData('special_price') || $product->hasData('group_price')) {
57+
$priceLow = $priceBlock->getFinalPrice();
58+
} else {
59+
$priceLow = ($priceView == 'Price Range') ? $priceBlock->getPriceFrom() : $priceBlock->getRegularPrice();
60+
}
5861

5962
\PHPUnit_Framework_Assert::assertEquals(
6063
$priceData['price_from'],
6164
$priceLow,
6265
'Bundle price From on product view page is not correct.'
6366
);
6467

65-
if ($product->getPriceView() == 'Price Range') {
68+
if ($priceView == 'Price Range') {
6669
\PHPUnit_Framework_Assert::assertEquals(
6770
$priceData['price_to'],
6871
$priceBlock->getPriceTo(),
@@ -72,7 +75,7 @@ protected function assertPrice(BundleProduct $product, CatalogProductView $catal
7275
}
7376

7477
/**
75-
* Returns a string representation of the object
78+
* Returns a string representation of the object.
7679
*
7780
* @return string
7881
*/

dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,35 @@
99
use Magento\Catalog\Test\Constraint\AssertProductPage;
1010

1111
/**
12-
* Class AssertBundleProductPage
12+
* Check displayed product price on product page(front-end).
1313
*/
1414
class AssertBundleProductPage extends AssertProductPage
1515
{
1616
/**
17-
* Verify displayed product price on product page(front-end) equals passed from fixture
17+
* Verify displayed product price on product page(front-end) equals passed from fixture.
1818
*
1919
* @return string|null
20+
*
21+
* @SuppressWarnings(PHPMD.NPathComplexity)
2022
*/
2123
protected function verifyPrice()
2224
{
2325
$priceData = $this->product->getDataFieldConfig('price')['source']->getPreset();
26+
$priceView = $this->product->getPriceView();
2427
$priceBlock = $this->productView->getPriceBlock();
25-
$priceLow = ($this->product->getPriceView() == 'Price Range')
26-
? $priceBlock->getPriceFrom()
27-
: $priceBlock->getRegularPrice();
28+
29+
if ($this->product->hasData('special_price') || $this->product->hasData('group_price')) {
30+
$priceLow = $priceBlock->getFinalPrice();
31+
} else {
32+
$priceLow = ($priceView == 'Price Range') ? $priceBlock->getPriceFrom() : $priceBlock->getRegularPrice();
33+
}
34+
2835
$errors = [];
2936

3037
if ($priceData['price_from'] != $priceLow) {
3138
$errors[] = 'Bundle price "From" on product view page is not correct.';
3239
}
33-
if ($this->product->getPriceView() == 'Price Range' && $priceData['price_to'] != $priceBlock->getPriceTo()) {
40+
if ($priceView == 'Price Range' && $priceData['price_to'] != $priceBlock->getPriceTo()) {
3441
$errors[] = 'Bundle price "To" on product view page is not correct.';
3542
}
3643

dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleDynamicTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
*/
1717
class BundleDynamicTest extends Functional
1818
{
19+
/* tags */
20+
const TEST_TYPE = 'acceptance_test';
21+
/* end tags */
22+
1923
/**
2024
* Login into backend area before test
2125
*

dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/BundleFixedTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
*/
1717
class BundleFixedTest extends Functional
1818
{
19+
/* tags */
20+
const TEST_TYPE = 'acceptance_test';
21+
/* end tags */
22+
1923
/**
2024
* Login into backend area before test
2125
*

0 commit comments

Comments
 (0)