Skip to content

Commit 7436c27

Browse files
committed
MAGETWO-58144: [FT] Magento\Catalog\Test\TestCase\Product\ProductTypeSwitchingOnCreationTest fail on Bamboo
1 parent b55989d commit 7436c27

File tree

5 files changed

+53
-14
lines changed

5 files changed

+53
-14
lines changed

app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Button/Save.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,12 @@
88
use Magento\Ui\Component\Control\Container;
99
use Magento\Catalog\Block\Adminhtml\Product\Edit\Button\Generic;
1010
use Magento\ConfigurableProduct\Model\Product\Type\Configurable as ConfigurableType;
11-
use Magento\Catalog\Model\Product\Type;
1211

1312
/**
1413
* Class Save
1514
*/
1615
class Save extends Generic
1716
{
18-
/**
19-
* @var array
20-
*/
21-
private static $availableProductTypes = [
22-
ConfigurableType::TYPE_CODE,
23-
Type::TYPE_SIMPLE,
24-
Type::TYPE_VIRTUAL
25-
];
26-
2717
/**
2818
* {@inheritdoc}
2919
*/
@@ -165,6 +155,6 @@ protected function getSaveAction()
165155
*/
166156
protected function isConfigurableProduct()
167157
{
168-
return in_array($this->getProduct()->getTypeId(), self::$availableProductTypes);
158+
return !$this->getProduct()->isComposite() || $this->getProduct()->getTypeId() === ConfigurableType::TYPE_CODE;
169159
}
170160
}

app/code/Magento/ConfigurableProduct/Test/Unit/Block/Adminhtml/Product/Edit/Button/SaveTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected function setUp()
3838
->disableOriginalConstructor()
3939
->getMock();
4040
$this->productMock = $this->getMockBuilder(ProductInterface::class)
41-
->setMethods(['isReadonly', 'isDuplicable'])
41+
->setMethods(['isReadonly', 'isDuplicable', 'isComposite'])
4242
->getMockForAbstractClass();
4343

4444
$this->registryMock->expects(static::any())

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew;
1111
use Magento\Mtf\Fixture\FixtureFactory;
1212
use Magento\Mtf\TestCase\Injectable;
13+
use Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable;
1314

1415
/**
1516
* Test Creation for ProductTypeSwitchingOnCreation
@@ -75,18 +76,49 @@ public function __inject(
7576
*
7677
* @param string $createProduct
7778
* @param string $product
79+
* @param string $actionName
7880
* @return array
7981
*/
80-
public function test($createProduct, $product)
82+
public function test(string $createProduct, string $product, string $actionName = null): array
8183
{
8284
// Steps
8385
list($fixture, $dataset) = explode('::', $product);
8486
$product = $this->fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
8587
$this->catalogProductIndex->open();
8688
$this->catalogProductIndex->getGridPageActionBlock()->addProduct($createProduct);
89+
if ($actionName) {
90+
$this->performAction($actionName);
91+
}
8792
$this->catalogProductNew->getProductForm()->fill($product);
8893
$this->catalogProductNew->getFormPageActions()->save($product);
8994

9095
return ['product' => $product];
9196
}
97+
98+
/**
99+
* Perform action.
100+
*
101+
* @param string $actionName
102+
* @return void
103+
*/
104+
private function performAction(string $actionName): void
105+
{
106+
if (method_exists(__CLASS__, $actionName)) {
107+
$this->$actionName();
108+
}
109+
}
110+
111+
/**
112+
* Clear downloadable product data.
113+
*
114+
* @return void
115+
*/
116+
private function clearDownloadableData(): void
117+
{
118+
$this->catalogProductNew->getProductForm()->openSection('downloadable_information');
119+
/** @var Downloadable $downloadableInfoTab */
120+
$downloadableInfoTab = $this->catalogProductNew->getProductForm()->getSection('downloadable_information');
121+
$downloadableInfoTab->getDownloadableBlock('Links')->clearDownloadableData();
122+
$downloadableInfoTab->setIsDownloadable('No');
123+
}
92124
}

dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<variation name="ProductTypeSwitchingOnCreationTestVariation9">
7777
<data name="createProduct" xsi:type="string">downloadable</data>
7878
<data name="product" xsi:type="string">configurableProduct::not_virtual_for_type_switching</data>
79-
<data name="tag" xsi:type="string">to_maintain:yes</data>
79+
<data name="actionName" xsi:type="string">clearDownloadableData</data>
8080
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
8181
<constraint name="Magento\Catalog\Test\Constraint\AssertProductInGrid" />
8282
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertChildProductsInGrid" />

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,21 @@ public function setFieldsData(array $fields, SimpleElement $element = null)
104104

105105
return $this;
106106
}
107+
108+
/**
109+
* Set "Is this downloadable Product?" value.
110+
*
111+
* @param string $downloadable
112+
* @param SimpleElement|null $element
113+
* @return void
114+
*/
115+
public function setIsDownloadable(string $downloadable = 'Yes', SimpleElement $element = null): void
116+
{
117+
$context = $element ?: $this->_rootElement;
118+
$isDownloadable = $context->find($this->isDownloadableProduct);
119+
$value = 'Yes' == $downloadable ? '1' : '0';
120+
if ($isDownloadable->isVisible() && $isDownloadable->getAttribute('value') != $value) {
121+
$isDownloadable->click();
122+
}
123+
}
107124
}

0 commit comments

Comments
 (0)