Skip to content

Commit d89369d

Browse files
committed
Merge branch 'grouped-product' of github.com:magento-qmt/magento2ce into PR
2 parents 39b9fdc + 629b937 commit d89369d

File tree

27 files changed

+786
-114
lines changed

27 files changed

+786
-114
lines changed

dev/tests/functional/.htaccess.sample

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
###########################################
2-
## Allow access to command.php
3-
<Files command.php>
1+
##############################################
2+
## Allow access to command.php and website.php
3+
<FilesMatch "command.php|website.php">
44
order allow,deny
55
allow from all
6-
</Files>
6+
</FilesMatch>

dev/tests/functional/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc43",
4-
"php": "~5.6.0|7.0.2|7.0.4|~7.0.6",
3+
"magento/mtf": "1.0.0-rc44",
4+
"php": "~5.6.0|7.0.2|~7.0.6",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2"
77
},
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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;
8+
9+
use Magento\Mtf\Util\Protocol\CurlInterface;
10+
use Magento\Mtf\Util\Protocol\CurlTransport;
11+
12+
/**
13+
* Perform Website folder creation for functional tests executions.
14+
*/
15+
class Website
16+
{
17+
/**
18+
* Url to website.php.
19+
*/
20+
const URL = 'dev/tests/functional/utils/website.php';
21+
22+
/**
23+
* Curl transport protocol.
24+
*
25+
* @var CurlTransport
26+
*/
27+
private $transport;
28+
29+
/**
30+
* @constructor
31+
* @param CurlTransport $transport
32+
*/
33+
public function __construct(CurlTransport $transport)
34+
{
35+
$this->transport = $transport;
36+
}
37+
38+
/**
39+
* Creates Website folder in root directory.
40+
*
41+
* @param string $websiteCode
42+
* @throws \Exception
43+
*/
44+
public function create($websiteCode)
45+
{
46+
$curl = $this->transport;
47+
$curl->addOption(CURLOPT_HEADER, 1);
48+
$curl->write($this->prepareUrl($websiteCode), [], CurlInterface::GET);
49+
$curl->read();
50+
$curl->close();
51+
}
52+
53+
/**
54+
* Prepare url.
55+
*
56+
* @param string $websiteCode
57+
* @return string
58+
*/
59+
private function prepareUrl($websiteCode)
60+
{
61+
return $_ENV['app_frontend_url'] . Website::URL . '?website_code=' . urldecode($websiteCode);
62+
}
63+
}

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/BundleProduct.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<field name="affect_bundle_product_selection" />
9191
<field name="stock_data" group="advanced-inventory" />
9292
<field name="category_id" group="product-details" />
93-
<field name="website_ids" group="websites" />
93+
<field name="website_ids" group="websites" source="Magento\Catalog\Test\Fixture\Product\WebsiteIds" />
9494
<field name="cross_sell_products" group="related" source="Magento\Catalog\Test\Fixture\Product\UpSellProducts" />
9595
<field name="up_sell_products" group="related" source="Magento\Catalog\Test\Fixture\Product\CrossSellProducts" />
9696
<field name="related_products" group="related" source="Magento\Catalog\Test\Fixture\Product\RelatedProducts" />

dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<item name="dataset" xsi:type="string">bundle_dynamic_with_category</item>
1818
</field>
1919
<field name="website_ids" xsi:type="array">
20-
<item name="0" xsi:type="string">Main Website</item>
20+
<item name="0" xsi:type="array">
21+
<item name="dataset" xsi:type="string">default</item>
22+
</item>
2123
</field>
2224
<field name="bundle_selections" xsi:type="array">
2325
<item name="dataset" xsi:type="string">default_dynamic</item>
@@ -44,7 +46,9 @@
4446
<item name="dataset" xsi:type="string">taxable_goods</item>
4547
</field>
4648
<field name="website_ids" xsi:type="array">
47-
<item name="0" xsi:type="string">Main Website</item>
49+
<item name="0" xsi:type="array">
50+
<item name="dataset" xsi:type="string">default</item>
51+
</item>
4852
</field>
4953
<field name="stock_data" xsi:type="array">
5054
<item name="manage_stock" xsi:type="string">Yes</item>
@@ -83,7 +87,9 @@
8387
<field name="status" xsi:type="string">Yes</field>
8488
<field name="shipment_type" xsi:type="string">Together</field>
8589
<field name="website_ids" xsi:type="array">
86-
<item name="0" xsi:type="string">Main Website</item>
90+
<item name="0" xsi:type="array">
91+
<item name="dataset" xsi:type="string">default</item>
92+
</item>
8793
</field>
8894
<field name="stock_data" xsi:type="array">
8995
<item name="manage_stock" xsi:type="string">Yes</item>
@@ -117,7 +123,9 @@
117123
<field name="weight" xsi:type="string">1</field>
118124
<field name="weight_type" xsi:type="string">No</field>
119125
<field name="website_ids" xsi:type="array">
120-
<item name="0" xsi:type="string">Main Website</item>
126+
<item name="0" xsi:type="array">
127+
<item name="dataset" xsi:type="string">default</item>
128+
</item>
121129
</field>
122130
<field name="category_ids" xsi:type="array">
123131
<item name="dataset" xsi:type="string">default_subcategory</item>
@@ -137,7 +145,9 @@
137145
<item name="dataset" xsi:type="string">bundle_dynamic_with_category</item>
138146
</field>
139147
<field name="website_ids" xsi:type="array">
140-
<item name="0" xsi:type="string">Main Website</item>
148+
<item name="0" xsi:type="array">
149+
<item name="dataset" xsi:type="string">default</item>
150+
</item>
141151
</field>
142152
<field name="category_ids" xsi:type="array">
143153
<item name="dataset" xsi:type="string">default_subcategory</item>
@@ -162,7 +172,9 @@
162172
<field name="weight" xsi:type="string">1</field>
163173
<field name="weight_type" xsi:type="string">No</field>
164174
<field name="website_ids" xsi:type="array">
165-
<item name="0" xsi:type="string">Main Website</item>
175+
<item name="0" xsi:type="array">
176+
<item name="dataset" xsi:type="string">default</item>
177+
</item>
166178
</field>
167179
<field name="shipment_type" xsi:type="string">Separately</field>
168180
<field name="bundle_selections" xsi:type="array">
@@ -193,7 +205,9 @@
193205
<field name="status" xsi:type="string">Yes</field>
194206
<field name="shipment_type" xsi:type="string">Together</field>
195207
<field name="website_ids" xsi:type="array">
196-
<item name="0" xsi:type="string">Main Website</item>
208+
<item name="0" xsi:type="array">
209+
<item name="dataset" xsi:type="string">default</item>
210+
</item>
197211
</field>
198212
<field name="stock_data" xsi:type="array">
199213
<item name="manage_stock" xsi:type="string">Yes</item>

dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Section/Websites/StoreTree.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\Mtf\Client\Element\SimpleElement;
1111

1212
/**
13-
* Typified element class for store tree element
13+
* Typified element class for store tree element.
1414
*/
1515
class StoreTree extends SimpleElement
1616
{
@@ -19,14 +19,14 @@ class StoreTree extends SimpleElement
1919
*
2020
* @var string
2121
*/
22-
protected $website = './/input[contains(@name, "product[website_ids]")]';
22+
protected $website = './/label[contains(text(), "%s")]';
2323

2424
/**
2525
* Selector for selected website checkbox.
2626
*
2727
* @var string
2828
*/
29-
protected $selectedWebsite = './/input[contains(@name, "product[website_ids][%d]") and not(@value="0")]/../label';
29+
protected $selectedWebsite = '(.//input[contains(@name, "product[website_ids]") and not(@value="0")])[%d]/../label';
3030

3131
/**
3232
* Set value.
@@ -37,6 +37,8 @@ class StoreTree extends SimpleElement
3737
*/
3838
public function setValue($values)
3939
{
40+
$this->clearValue();
41+
4042
$values = is_array($values) ? $values : [$values];
4143
foreach ($values as $value) {
4244
$website = $this->find(sprintf($this->website, $value), Locator::SELECTOR_XPATH);
@@ -67,4 +69,16 @@ public function getValue()
6769
}
6870
return $values;
6971
}
72+
73+
/**
74+
* Clear selected checkboxes.
75+
*
76+
* @return void
77+
*/
78+
private function clearValue()
79+
{
80+
foreach ($this->getValue() as $value) {
81+
$this->find(sprintf($this->website, $value), Locator::SELECTOR_XPATH)->click();
82+
}
83+
}
7084
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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\AbstractAssertForm;
12+
use Magento\Mtf\Fixture\FixtureInterface;
13+
14+
/**
15+
* Assert that Product is present on Custom Website and absent on Main Website.
16+
*/
17+
class AssertProductOnCustomWebsite extends AbstractAssertForm
18+
{
19+
/**
20+
* Message on the product page 404.
21+
*/
22+
const NOT_FOUND_MESSAGE = 'Whoops, our bad...';
23+
24+
/**
25+
* Product view.
26+
*
27+
* @var CatalogProductView
28+
*/
29+
protected $productViewPage;
30+
31+
/**
32+
* Browser.
33+
*
34+
* @var BrowserInterface
35+
*/
36+
protected $browser;
37+
38+
/**
39+
* Assert Product is present on Custom Website and absent on Main Website:
40+
* 1. Product is absent on Main Website.
41+
* 2. Product is present on Custom Website.
42+
*
43+
* @param BrowserInterface $browser
44+
* @param CatalogProductView $catalogProductView
45+
* @param FixtureInterface $product
46+
* @return void
47+
*/
48+
public function processAssert(
49+
BrowserInterface $browser,
50+
CatalogProductView $catalogProductView,
51+
FixtureInterface $product
52+
) {
53+
$this->browser = $browser;
54+
$this->productViewPage = $catalogProductView;
55+
56+
$this->verifyProductOnMainWebsite($product);
57+
$this->verifyProductOnCustomWebsite($product);
58+
}
59+
60+
/**
61+
* Verify Product is absent on Main Website.
62+
*
63+
* @param FixtureInterface $product
64+
* @return void
65+
*/
66+
protected function verifyProductOnMainWebsite(FixtureInterface $product)
67+
{
68+
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
69+
70+
\PHPUnit_Framework_Assert::assertEquals(
71+
self::NOT_FOUND_MESSAGE,
72+
$this->productViewPage->getTitleBlock()->getTitle(),
73+
'Product ' . $product->getName() . ' is available on Main Website, but should not.'
74+
);
75+
}
76+
77+
/**
78+
* Verify Product is present on assigned custom websites.
79+
*
80+
* @param FixtureInterface $product
81+
* @return void
82+
*/
83+
protected function verifyProductOnCustomWebsite(FixtureInterface $product)
84+
{
85+
$websites = $product->getDataFieldConfig('website_ids')['source']->getWebsites();
86+
foreach ($websites as $website) {
87+
$this->browser->open(
88+
$_ENV['app_frontend_url'] . 'websites/' . $website->getCode() . '/' . $product->getUrlKey() . '.html'
89+
);
90+
91+
\PHPUnit_Framework_Assert::assertEquals(
92+
$product->getName(),
93+
$this->productViewPage->getViewBlock()->getProductName(),
94+
'Product ' . $product->getName() . ' is not available on ' . $website->getName() . ' website.'
95+
);
96+
}
97+
}
98+
99+
/**
100+
* Returns a string representation of the object.
101+
*
102+
* @return string
103+
*/
104+
public function toString()
105+
{
106+
return 'Product on product view page displayed in appropriate Website.';
107+
}
108+
}

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductSimple.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<field name="attribute_set_id" group="product-details" source="Magento\Catalog\Test\Fixture\Product\AttributeSetId" />
7676
<field name="custom_attribute" source="Magento\Catalog\Test\Fixture\CatalogProductSimple\CustomAttribute" />
7777
<field name="custom_options" is_required="0" group="customer-options" source="Magento\Catalog\Test\Fixture\Product\CustomOptions" repository="Magento\Catalog\Test\Repository\Product\CustomOptions" />
78-
<field name="website_ids" group="websites" />
78+
<field name="website_ids" group="websites" source="Magento\Catalog\Test\Fixture\Product\WebsiteIds" />
7979
<field name="is_returnable" is_required="0" group="product-details" />
8080
<field name="news_from_date" is_required="0" source="Magento\Backend\Test\Fixture\Source\Date" />
8181
<field name="news_to_date" is_required="0" source="Magento\Backend\Test\Fixture\Source\Date" />

dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/CatalogProductVirtual.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
<field name="product_has_weight" group="product-details" />
7979
<field name="attribute_set_id" group="product-details" source="Magento\Catalog\Test\Fixture\Product\AttributeSetId" />
8080
<field name="custom_options" is_required="0" group="customer-options" source="Magento\Catalog\Test\Fixture\Product\CustomOptions" repository="Magento\Catalog\Test\Repository\Product\CustomOptions" />
81-
<field name="website_ids" group="websites" />
81+
<field name="website_ids" group="websites" source="Magento\Catalog\Test\Fixture\Product\WebsiteIds" />
8282
<field name="checkout_data" group="null" repository="Magento\Catalog\Test\Repository\CatalogProductVirtual\CheckoutData" />
8383
<field name="cross_sell_products" group="related" source="Magento\Catalog\Test\Fixture\Product\RelatedProducts" />
8484
<field name="up_sell_products" group="related" source="Magento\Catalog\Test\Fixture\Product\RelatedProducts" />

0 commit comments

Comments
 (0)